|| operator is or. : Boolean Operators « Language Basics « Ruby






|| operator is or.


# When you use || or or, if any of the statements are true, the code executes:

ruby = "nifty"
programming = "fun"
if ruby == "nifty" or programming == "fun"
  puts "or!"
end

 








Related examples in the same category

1.the && operator means "and."
2.have more than two statements separated by &&
3.use the keyword and instead of &&.
4.check whether one or the other is true by using ||
5.Are more than two statements OK?
6.Chaining together multiple comparisons is also possible with a clever use of parentheses:
7.And, or and Not
8.Use or in if statement