Code Editor
Control Flow in Ruby

Billions of Booleans

Home stretch! Let's go over boolean operators.

( 1 == 1 ) && ( 2 == 2 ) # true ( 1 == 2 ) || ( 2 == 2 ) # true !( false ) # true
  1. With && both comparisons on the left and right must evaluate to true for the entire statement to return true. If the left side does not return true it will not bother trying the right side
  2. With || either the right or left side must evaluate to true. If the left side evaluates to true, the right side will not be tried because it has met the condition of one side being true.
  3. With ! you reverse the result. If you're false you're now true. if you're true you're now false! Just think of it as opposite day!
Report a Bug
If you see a bug or any other issue with this page, please report it here.