diff --git a/Base/Structures/MaybeExtensions.cs b/Base/Structures/MaybeExtensions.cs index 0974bd4..1bd9ef9 100644 --- a/Base/Structures/MaybeExtensions.cs +++ b/Base/Structures/MaybeExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; namespace FruityFoundation.Base.Structures; @@ -23,4 +24,10 @@ public static class MaybeExtensions public static T? ToNullable(this Maybe item) where T : struct => item.HasValue ? item.Value : null; + + public static IEnumerable Choose(this IEnumerable enumerable, Func> mapper) => + enumerable + .Select(mapper) + .Where(x => x.HasValue) + .Select(x => x.Value); } \ No newline at end of file