Exemplo n.º 1
0
 /// <summary>
 /// Obtains first value in the sequence; or <see cref="Optional{T}.None"/>
 /// if sequence is empty.
 /// </summary>
 /// <typeparam name="T">Type of elements in the sequence.</typeparam>
 /// <param name="seq">A sequence to check. Cannot be <see langword="null"/>.</param>
 /// <returns>The first element in the sequence; or <see cref="Optional{T}.None"/> if sequence is empty. </returns>
 public static Optional <T> FirstOrEmpty <T>(IEnumerable <T> seq)
 => NewSequence.FirstOrEmpty(seq);
Exemplo n.º 2
0
 /// <summary>
 /// Returns the first element in a sequence that satisfies a specified condition.
 /// </summary>
 /// <typeparam name="T">The type of the elements of source.</typeparam>
 /// <param name="seq">A collection to return an element from.</param>
 /// <param name="filter">A function to test each element for a condition.</param>
 /// <returns>The first element in the sequence that matches to the specified filter; or empty value.</returns>
 public static Optional <T> FirstOrEmpty <T>(IEnumerable <T> seq, Predicate <T> filter)
     where T : notnull
 => NewSequence.FirstOrEmpty(seq, filter);