Default if empty

See also


Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.

res = obs = xs.defaultIfEmpty() obs = xs.defaultIfEmpty(False

Keyword arguments: default_value – The value to return if the sequence is empty. If not

provided, this defaults to None.

Returns an observable {Observable} sequence that contains the specified default value if the source is empty otherwise, the elements of the source itself.