[Solved] What does || exactly Mean? [duplicate]


The || operator is similar to the keyword or but is different from the keyword or in extremely important ways. Below are two great write-ups on the topic, comparing the two and showing you how to use either one:


The most important thing to note in what Avdi says, is that || cannot be used for flow control, whereas or can be.

For example…

a = :value
c = b || a
#de Since `b` is undefined/null, `c` will be set to `:value`

c = b || puts("Failure!") #de This will raise an exception!

c = b or puts("Failure!") #de Will set `c` to `NilClass` and output "Failure!"

1

solved What does || exactly Mean? [duplicate]