Skip to content

Instantly share code, notes, and snippets.

@TheFo2sh
Created February 23, 2020 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFo2sh/121c208a6e1bb235df32e43d51b89c68 to your computer and use it in GitHub Desktop.
Save TheFo2sh/121c208a6e1bb235df32e43d51b89c68 to your computer and use it in GitHub Desktop.
public static class OptionExtensions
{
public static Option<(TOuterA, TOuterB, TInner)> Intersect<TOuterA, TOuterB, TInner>(this Option<(TOuterA, TOuterB)> outer, Option<TInner> inner)
{
return outer.HasValue && inner.HasValue
? outer.Select(outer1 => (outer1.Item1,outer1.Item2, inner.ValueOrFailure()))
: Option.None<(TOuterA, TOuterB, TInner)>();
}
public static Option<(TOuter,TInner)> Intersect<TOuter, TInner>(this Option<TOuter> outer,Option<TInner> inner)
{
return outer.HasValue && inner.HasValue
? outer.Select(outer1 => (outer1, inner.ValueOrFailure()))
: Option.None<(TOuter, TInner)>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment