Re:Avoid Else, Return Early (2013)
by crooked-v on Monday March 26, 2018 @03:05PM
(#16681537)
And in Javascript, once do-expressions go from a proposal to a common part of the language, this will be a thing:
...which is even closer to the Elixir style than JS's ternary operator (which is identical to Java's).
[ Parent
| on HN ]
What's the advantage over JS's ternary operator?
I guess it depends on whether "if" is treated as an expression which returns a value, which I don't think is the case due to the fact that I don't think there is an implicit value return in JS (such as in Ruby; the final line in any scope is the value that scope returns; same as in Elixir)