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

Perhaps a Python style spelt-out `not` for boolean negation would have been a better solution for this than `unless` in deep retrospect?

    send_email if not user_suspended?


Ruby has "not", but the precedence rules between "not" and "!" differ


Well I really showed myself up as commenting on a topic that I know nothing about! :-)

But that's actually ideal in this context, a really low precedence operator is exactly what you want because you can swap `unless` for `if not` without worring about extra parentheses:

send_email if not user_suspended? || user_opt_out?


I wouldn't use this. Relying on tricky operator precedence can trip up your readers. It's better to just wrap everything in parentheses. I also use parentheses when mixing && and ||, even though their precedence relationship is (probably) more widely known.

I generally avoid `not`, `and`, `or` keywords.




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

Search: