|
|
|
|
|
by bookface
4537 days ago
|
|
Can anybody explain some good use cases of implicit return? When I was doing a project in CoffeeScript last year (the only time I've used it), I found myself just using the return keyword explicitly because it was more readable, and I never ran into the issue the article talks about where it can be bad to accidentally return something from a function that should return null/undefined. When would implicit return make code better? Maybe I'm answering my own question, but I can see them being more readable to somebody coming from a Haskell or LISP background than to somebody like me who has worked mostly in C, Java, and Python. |
|
Ruby also has explicit returns. The idea is, every statement is an expression, and so has a return value. You don't need to figure out about whether a statement does or not, it just always does. One less thing to have to think about.
Other things, too, but that's one that that sticks out for me.