FunSharp.Common/EitherExtensions.cs
//--------------------------------------------------
/// <summary>
/// Discards the right value and converts <paramref name="either" />
/// to an <see cref="IEnumerable{T}"/>.
/// </summary>
Discards the right value and converts
to an .
Discards the right value and converts to an .
[NotNull]
        public static IEnumerable<TLeft> ToLeftEnumerable<TLeft, TRight>([NotNull] this Either<TLeft, TRight> either)
        {
            if (either is null) throw new ArgumentNullException(nameof(either));
            switch (either)
            {
                case EitherLeft<TLeft, TRight> left:
                    yield return left.Value;
                    break;
                case EitherRight<TLeft, TRight> _:
                    yield break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(either));
            }
        }
[ NotNull ] public static IEnumerable < TLeft > ToLeftEnumerable < TLeft , TRight > ( [ NotNull ] this Either < TLeft , TRight > either ) { if ( either is null ) throw new ArgumentNullException ( nameof ( either ) ) ; switch ( either ) { case EitherLeft < TLeft , TRight > left : yield return left . Value ; break ; case EitherRight < TLeft , TRight > _ : yield break ; default : throw new ArgumentOutOfRangeException ( nameof ( either ) ) ; } }
Discards the right value and converts
to an .
Discards the right value and converts to an .
this
[NotNull]