Comment

Comment by natefaubion

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.
parent natefaubion 14 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton