TEnumerable.DefaultIfEmpty<T> Method
Overloads
| DefaultIfEmpty<T>(IEnumerable<T>) |
Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty. |
| DefaultIfEmpty<T>(IEnumerable<T>, T) |
Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty. |
Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.
class function DefaultIfEmpty<T>(const source: IEnumerable<T>): IEnumerable<T>
Type Parameters
- T
The type of the elements of source .
Parameters
- source
- IEnumerable<T>
The sequence to return a default value for if it is empty.
Returns
A sequence that contains Default(T) if source is empty;
otherwise, source .
Exceptions
source is nil .
Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
class function DefaultIfEmpty<T>(const source: IEnumerable<T>; const defaultValue: T): IEnumerable<T>
Type Parameters
- T
The type of the elements of source .
Parameters
- source
- IEnumerable<T>
The sequence to return a default value for if it is empty.
- defaultValue
- T
The value to return if the sequence is empty.
Returns
A sequence that contains defaultValue if source is
empty; otherwise, source .
Exceptions
source is nil .