June 2017
Beginner
330 pages
7h 30m
English
To review, I'm going to start off with a regular if statement:
x = 10 y = 100 z = 10 if x == y puts "x is equal to y" end
If you run this program, nothing will print out since x is not equal to y. This is what you already know. Now, I'm going to add some additional scenarios:
if x == y puts "x is equal to y" elsif x > z puts "x is greater than z" else puts "Something else" end
Essentially, this code is going to check if x is equal to y, and if it's not, it moves down to the next condition and checks if x is greater than z, which if not true again means that, it finally prints Something else. Whenever you have an else statement in a program like this, it will be treated like a fallback value, which ...
Read now
Unlock full access