-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Func<> equivalent to Execute Action<> Maybe extension #10
base: master
Are you sure you want to change the base?
Conversation
Alternatively, the following is more comprehensive but extends Nullable<> as well. I didn't know if you wanted to go that far...
|
Thanks for the contribution! Did you consider the Select extension method? It seems like it does exactly what you need (transforms a I see now that the naming I've chosen is probably confusing. Do you think both Regarding extensions for structs - I like the idea! |
I did completely miss that 😞 I was looking for something similar to OnSuccess() for Result<>. I think Select is the logical choice, I'll work with that for now. |
Still great suggestion regarding structs! I'll add it soon and will roll out a new version of the lib. |
As overloads to Select? I'm happy to amend the PR if that helps? |
Yes.
Would be very helpful, thanks! |
So I've run into a blocker here. The methods
and
have the same signature. Despite the different type constraints. More info here https://blogs.msdn.microsoft.com/ericlippert/2009/12/10/constraints-are-not-part-of-the-signature/ The solution to this isn't immediately apparent to me 😕 (My original code had |
Ah, indeed, return values also don't count as overloads. |
@@ -69,5 +69,14 @@ public static void Execute<T>(this Maybe<T> maybe, Action<T> action) | |||
|
|||
action(maybe.Value); | |||
} | |||
|
|||
public static TOut Execute<T, TOut>(this Maybe<T> maybe, Func<T, TOut> func) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Map
method, not like Execute
or Select
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select
== Map
in C#. Found some conflicts merging this PR. Could you re-submit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@a-z-hub Ping!
Is this still active?
@laurence79 Is this PR still active? Please, fix the merge conflicts or say something :) |
Great library, love the approach and your Enterprise Craftsmanship series 😊
When using the library in my own project I found that I sometimes wanted to return a value from the Maybe<>.Execute() extension method, so I've added a Func<> overload in this PR in the hope that it might be of use to others.