Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Postfix conditionals are pretty nice for conditional statements that are particularly unlikely to happen. Imagine, in a function body:

    read(file)
    write(file) unless terriblyUnlikelyThingHappens
    return results
... it helps to keep the expected main-line flow of your instructions reading smoothly -- much the same as the way you'd tend to use it in English. Doing it the "normal" way instead:

    read(file)
    if (!terriblyUnlikelyThingHappens) {
      write(file)
    }
    return results
... makes it a bit more difficult to follow what should be going on in the function.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: