What's the difference between the
It's a matter of operator precedence.
|| has a higher precedence than
So, in between the two you have other operators including ternary (
? :) and assignment (
=) so which one you choose can affect the outcome of statements.
Here's a ruby operator precedence table.
See this question for another example using
Also, be aware of some nasty things that could happen:
a = false or true sets
a = false || true sets
= precedence is lower than
|| but higher than