When I evaluate the expression a = nil || 2008
in Irb, I get the answer as 2008 and a
is assigned the value 2008 which is correct as ||
operator return their first argument unless it is false
or nil
.
But when I do something like a = nil or 2008
on Irb console, a
is assigned nil
and the return value of the evaluation of the expression I get is still 2008.
Has it got something to do with operator precedence. I was just wondering why it works this way, can someone please shed some light on this ?