Method LastOrNone
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
LastOrNone<T>(IEnumerable<T>?)
Returns the last element of a sequence, if it has one.
[Pure]
public static Maybe<T> LastOrNone<T>(this IEnumerable<T>? source)
Parameters
sourceIEnumerable<T>The sequence to read. A null sequence counts as empty.
Returns
- Maybe<T>
A Maybe<T> containing the last element, and one containing no value if the sequence is empty.
Type Parameters
TThe type of the values in the sequence.
Remarks
This code indexes a sequence that permits an index. It enumerates each other sequence to the end to find out what the last element was.
LastOrNone<T>(IEnumerable<T>?, Func<T, bool>)
Returns the last element of a sequence which satisfies a predicate, if there is one.
[Pure]
public static Maybe<T> LastOrNone<T>(this IEnumerable<T>? source, Func<T, bool> predicate)
Parameters
sourceIEnumerable<T>The sequence to search. A null sequence counts as empty.
predicateFunc<T, bool>The condition the element must satisfy.
Returns
- Maybe<T>
A Maybe<T> containing the last matching element, and one containing no value if there is none.
Type Parameters
TThe type of the values in the sequence.