Hacker News new | ask | show | jobs
by Mordak 3391 days ago
I use ruby's trailing conditionals exactly this way all the time - it makes me happy to see someone else using the same pattern. I also use it at the start of functions in order to sanity check arguments:

    def do_something(arg1, arg2)
        return false if arg1.is_invalid
        return false if arg2 < sane
        ...
    end
The trailing `unless` is also handy, and I find it a bit nicer to read compared to a negated `if`.