Nil and boolean in Ruby
If first operand is falsy (nil
or false
), then, second operand of &&
will not be evaluated, as falsy && whatever
will be always falsy
The statement goes through the conditions in order, will stop when a falsy result is obtained and return the value of the last evaluation performed.
In contrary to &&
which stops at a falsy value, ||
will stop at a truthy value instead.