Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



I'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.


Indeed, "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

   # boolean expression
   if some_condition && some_other_condition
     do_something
   end

   # control flow
   document.saved? or document.save!


I'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?"


Agreed, it is not my example.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: