3 ms·
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
by quietbritishjim 4y ago
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?
- jjgreen 4y agoRuby has "not", but the precedence rules between "not" and "!" differ
- quietbritishjim 4y agoWell 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?
- greenpeas 4y agoI 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.