OptionExtensionsLinqLastOrNone Method

Overload List

LastOrNoneT(IEnumerableT) Returns Some of the last element of the collection if it is non-empty; None otherwise.
C#
Assert(Array.Empty<Title>().FirstOrNone().IsNone);
Assert((new int[2] { 1, 2 }).LastOrNone() == Some(2));
LastOrNoneT(IEnumerableT, FuncT, Boolean) Returns Some of the last element of the collection satisfying the filter if any; None otherwise.
C#
Assert(Array.Empty<int>().LastOrNone(x => x > 2).IsNone);
Assert((new int[2] { 2, 1 }).LastOrNone(x => x > 2).IsNone);
Assert((new int[2] { 2, 1 }).LastOrNone(x => x > 1) == Some(2));

See Also