|
|
|
|
|
by devrob
901 days ago
|
|
Side tangent: I love Ruby, but strongly dislike and discourage `unless` in the code base. It still trips me up having written Ruby 5 years at this stage. Maybe its just me but I still pause every time for myself when looking at `unless` with a multi conditional. Example: 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.