Re:JS 2 CoffeeScript Compiler
by TrevorBurnham on Wednesday September 14, 2011 @10:57AM
(#2996486)
It looks weird at first, but it's great when used like so:
Keeping all of your "return"s at the start of the line makes it much easier to see, at a glance, what the possible return values of your function are. (And, of course, when you see a "return" in the middle of your function, you know there must be a condition attached.)
[ Parent
| on HN ]
The traditional alternative also puts your returns at the beginnings of lines. It just uses a lot more lines.
if (!err) {
return x;
}
if (condition) {
return y;
}
...