Skip to content
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

Why do you have to create a success option manually with Option<T>.flatmap? #133

Open
HIMISOCOOL opened this issue Jul 9, 2018 · 1 comment

Comments

@HIMISOCOOL
Copy link

for Option.flatMap the failure branch returns a None but the success branch only returns the function value

if (this._isEmpty) return None
else return f(this.value as A)

where as with Map

return this._isEmpty ? None : Some(f(this.value as A))

The result is boxed.
Is there a reason for this?

@sledorze
Copy link

@HIMISOCOOL f function taken as param of flatMap already does boxing.
That's standard FP behavior.
The result of both functions map and flatMap are an Option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants