6 ms·
Scanning through the Ruby styleguide for GitHub-specific changes I found this gem: "The and and or keywords are banned. It's just not worth it. Always use && a
by mutewinter 14y ago
Scanning through the Ruby styleguide for GitHub-specific changes I found this gem:
"The and and or keywords are banned. It's just not worth it. Always use && and || instead."
sad trombone
- jeltz 14y agoIndeed, "and" and "or" are excellent for their intended use, for control flow. Like explained by the style guide the Github one is based on. https://github.com/bbatsov/ruby-style-guide https://github.com/bbatsov/ruby-style-guide # boolean expression if some_condition && some_other_condition do_something end # control flow document.saved? or document.save!
- 286c8cb04bda 14y agoI'm not sold on tossing "and" and "or" out the window, but wouldn't "document.saved? or document.save!" read better as "document.save! unless document.saved?"
- jeltz 14y agoAgreed, it is not my example.
- rtomayko 14y agoI'd agree with you if not for the many subtle and critical bugs I've seen introduced into our production environment due to and/or precedence problems. The increased expressiveness when used correctly is just not worth it.