0

Possible Duplicate:
Is there any wisdom behind “and”, “or” operators in Ruby ?

What is the difference, if any, between the following pairs of logical operators?

  1. && vs. and
  2. || vs. or
Community
  • 1
  • 1
keruilin
  • 16,782
  • 34
  • 108
  • 175
  • 4
    Covered in serveral questions, including [Is there any wisdom behide "and", "or" operator in Ruby ?](http://stackoverflow.com/questions/1434842/is-there-any-wisdom-behide-and-or-operator-in-ruby), [Ruby: difference between || and ‘or’](http://stackoverflow.com/questions/2083112/ruby-difference-between-and-or), [Difference between “and” and && in Ruby?](http://stackoverflow.com/questions/1426826/difference-between-and-and-in-ruby). In short, precedence. – Matthew Flaschen Jul 12 '10 at 03:04

1 Answers1

8

The "word" versions have lower precedence than the "symbol" versions. In fact, they have even lower precedence than assignment.

Chuck
  • 234,037
  • 30
  • 302
  • 389
  • This would explain why `@user = User.find_by_id('test2@example.com') or User.find_by_email('test2@example.com')` sets `@user` to nil even though the record exists. – Chloe Aug 13 '17 at 18:15