by devrob · 2y ago · 0 comments
def do_the_thing
return do_not_do_it unless first_conditional || second_conditional
okay_actually_do_it
endGlad that Rubocop is shipping with Rails though!
Yes, every `unless` could be rewritten with an `if` instead, certainly. But I like the implication of weight these keywords carry in English language. `unless` implies it's a minor condition, that the majority of runs should fall on the opposite side of the conditional, where as `if` does not -- both weights of the condition feel potentially equivilant-ish.
`unless admin?` is fine
`unless !admin?` is annoying `unless user.admin? && account.support?` leads to madness