Is it true that in most cases, in Ruby, it is best to use &&
, ||
instead of and
, or
, unless it is some special situations.
I think one of Ruby's design principles is to have least surprises as possible, so using and
, or or
actually have some surprises... such as and
not having a higher precedence than or
, while &&
has a higher precedence than ||
.
So I think in most cases, use &&
, ||
. In know in some special situations, it may require using and
, or
, but I think if those are intermixed with &&
, ||
, sooner or later it may create bugs when your coworkers who started in Ruby not so long ago need to edit your code.