'||' unequal 'or'

October 21, 2007

some simple ruby code:

a = nil || 23
b = nil or 23
puts "#{a==b}"

prints: false. Please explain! I mean explain in the sense of why not how it happens. Is it meaningful to put '||' and 'or' on a different level in the precedence hierarchy?

UPDATE: i checked a couple of times before i posted but still can't reproduce it a day later. don't know what was different yesterday, Jruby? confused, ... i seem that puts "#{a == b}" prints true. today.

share this: