Hacker News new | ask | show | jobs
by benmmurphy 2540 days ago
yeah this is kind of horrible once you get to high levels of nesting. in an imperative language you can return early in the error paths and your function will still be understandable. this doesn't work with a single return. you can easily have 6 guard statements in an imperative language and your function will be comprehensible try doing 6 levels of nesting in elixir and it will be a complete mess.
1 comments

Maybe the “OK” library [1] could be useful for you.

I would also welcome a better built-in idiom for early returns.

[1] https://hexdocs.pm/ok/readme.html