Booleans
Goals
Step 1
Type this in irb:15 < 5 15 > 5 15 >= 5 10 == 12
Step 2
Type this in irb:a = 'apple' b = 'banana' a == b puts a + b a = b puts a + b
Step 3
Type this in irb:a = 'apple' b = 'banana' a != bType this in irb:!true !false !(a == b)
Step 4
Type this in irb:# First let's define variables: yes = true no = false # Now experiment. Boolean rule 1: AND means everything must be true. # true and true are true yes and yes yes && yes # true and false fail the test - AND means everything must be true yes and no no and yes no and no # Boolean rule 2: OR says at least one must be true. yes or no yes || no yes or yes
Step 5
Type this in irb:'sandwich'.end_with?('h') 'sandwich'.end_with?('z') [1,2,3].include?(2) [1,2,3].include?(9) 'is my string'.empty? ''.empty? 'is this nil'.nil? nil.nil?
Explanation
Further Reading
Next Step:
Go on to Conditionals