-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
options.flatMap doesn't work with sugar.=>
#15880
Comments
Hello. And I don't think this is a problem that can be solved by implementing the |
Hi @GULPF, a possible solution is to use the do notation: import options
var x = some(1)
echo x.map(proc(y: int): int = y + 1) # ok
echo x.map do (y: auto) -> auto:
y + 1 # ok
echo x.flatMap(proc(y: int): Option[int] = some(y + 1)) # ok
echo x.flatMap do (y: int) -> auto:
some(y + 1) # ok Unfortunately, you have to specify at least |
IMO if you're going to use the do notation you might as well just write out the full proc (the do notation should be removed from the language :)). Here is a better workaround: echo x.flatMap((y: int) -> Option[int] => some(y + 1)) |
I'm embarrassed, I didn't know I could use |
Example
Additional Information
The text was updated successfully, but these errors were encountered: