-
Notifications
You must be signed in to change notification settings - Fork 8
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 Variant, match and tap #37
Comments
Hey, that's a good question. Do we have details about this new API, what's the motivation behind it, what problems does it solve etc.? Difficult to say without knowing that. |
It would allow you to get rid of if else branching in your code, making it a more readable control flow like the matching pattern in scala, kotlin, rust, etc. So instead of something like this: const result = createSomeResult()
if(result.ok) {
// Do something with result
}
// result is an error You can do something like this: match(createSomeResult(), {
Ok: val => // Happy path,
Err: val => // Error Path,
}) You can also do that with |
Thanks for the response. There's already a bunch of methods on |
Yes you're right. map And mapErr are providing basically the same functionality. |
Thank you for the updated library, are you interested in adding the Variant Implementation to enable matching, like proposed in this PR vultix#61 ? That would be a tremendous improvement
The text was updated successfully, but these errors were encountered: