News for hackers. Stuff that matters.
Re:CoffeeScript: less typing, bad readability by natefaubion on Monday September 17, 2012 @03:57PM (#4534537)
I find it helps when you use short-circuiting. The returns are the first thing you see, making it more obvious what is going on.

  myfn = (arg) ->
    return 1 if arg is "one"
    return 2 if arg is "two"
    return arg.toInt()
This is obviously a little contrived with such a short method, but helps when you have stuff to do between conditional returns.
Re:CoffeeScript: less typing, bad readability by epidemian on Monday September 17, 2012 @07:14PM (#4535392)
Yeah. The example is not very good, as it would probably be better to write as switch expression. But on a complex function, returning early can avoid the need to retain a lot of context in your head while reading that code. I find it especially helpful for returning/throwing on error conditions or breaking out of recursion.