Truthiness Both or and || will return the first item that evaluates as true from the left side to the right.
|
true or "this doesn't return" # => true true || "this doesn't return" # => true false || true # => true false || false # => false false or false or 1 or 2 # => 1 |
In Ruby any Object that exists is considered true. The only exceptions are false itself and nil.
|
nil || false or nil || 3 # => 3 |
Even unassigned symbols are considered true.
So whenever an or comparison is done only…
Continue Reading »