OptionExtensionsLinqFirstOrNone Method

Overload List

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

See Also