DEV Community

Discussion on: What language features/concepts do insiders of the language love and outsiders hate?

Collapse
 
databasesponge profile image
MetaDave 🇪🇺 • Edited

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.