I’m sure this is well-documented somewhere, but it tripped me up anyway.
As you may know, Ruby has operators “or” and ”||”, “and” and “&&”. In normal logic operations they appear to be interchangeable. However, there are differences that may bite you if you use the wrong one.
Let’s say you want to coalesce two values—that is, take the first value if it isn’t nil or false, otherwise the second value. Let a = nil and b = "foo". If you write c = a or b, you might expect c to be “foo”, but you would be mistaken.
It’s probably operator precedence, because c = (a or b) gets you what you want. If you prefer to lose visually-redundant parenthesis, c = a || b is your friend.
“and” and “&&” work similarly.