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!



The code in the editor indicates what value (true or false) we want each variable to have, and your job is to add an expression that evaluates to the correct value using boolean operators (&&, ||, or !).

Folder Icon

Take this course for free

Already have an account?