Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

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

Closed
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants