Ruby Conditionals
# logic values
# check if something is true or false
# Does 12 equal 1?
puts 12 == 1
# Is 3 less than 4?
puts 3 < 4
# Is 12 greater than or equal to 12?
puts 12 >= 12
# Combining conditions with AND
puts true && true
puts false && true
# Combining conditions with OR
puts true || false
puts false || false
# Making decisions based on conditions
def taste(food)
if food == "bacon"
puts "Yummy!!! BACON!!!"
end
end
taste "spinach"
taste "bacon"
# function that prints Yummy!!! BACON!!! in the console if the input parameter is bacon
# else
def taste(bacon)
if bacon == "bacon"
puts "Yummy!!! BACON!!!"
else
puts "Urgh..."
end
end
taste "spinach"
taste "bacon"