1

So I have just (accidentally) discovered that Ruby allows the following Syntax:

if foo and bar

or

if foo or bar.

How (if at all?) is this different from

if foo && bar

if foo || bar

Are the operators different? How?

Abraham P
  • 15,029
  • 13
  • 58
  • 126

1 Answers1

3

Are the operators different?

Yes they are as per the operator precedence.

How?

For more information see Difference between “and” and && in Ruby? and Difference between “or” and || in Ruby?

Community
  • 1
  • 1
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317