Yes, and the same is true for English speakers as well I think.
I like to avoid #unless by ensuring that there is an inverse logical test available, just as #any? and #empty? are inverses.
I think that some Rails developers don't realise that just as you can call #valid? on a model, you can also call #invalid?, so you can avoid do_this unless my_model.valid? in favour of do_this if my_model.invalid?.
I think the latter reads much better.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes, and the same is true for English speakers as well I think.
I like to avoid
#unless
by ensuring that there is an inverse logical test available, just as#any?
and#empty?
are inverses.I think that some Rails developers don't realise that just as you can call
#valid?
on a model, you can also call#invalid?
, so you can avoiddo_this unless my_model.valid?
in favour ofdo_this if my_model.invalid?
.I think the latter reads much better.