3 ms·
You should look at the second part of the blog post[1]. It shows how to get around the "arrow anti-pattern" using map, filter, flatMap and for-comprehensions in
by tikhonj 14y ago
You should look at the second part of the blog post[1]. It shows how to get around the "arrow anti-pattern" using map, filter, flatMap and for-comprehensions in Scala. It's actually both simple and elegant! Also not very hard to understand.
[1]: https://blog.stackmob.com/2013/01/free-yourself-from-the-tyranny-of-null-part-2-why-weve-banned-null-in-our-codebase/ https://blog.stackmob.com/2013/01/free-yourself-from-the-tyr...
What you're actually doing is using the Option monad in Scala, but the article doesn't tell you that to avoid scaring you. And it succeeds: the pattern described in the second part of the blog post is easy to follow and clearly has no magic.