Key Concepts

Review core concepts you need to learn to master this subject

elsif Statements in Ruby

print "enter a number: " num = gets.chomp num = num.to_i; if num == 5 print "number is 5" elsif num == 10 print "number is 10" elsif num == 11 print "number is 11" else print "number is something other than 5, 10, or 11" end

In Ruby, an elsif statement can be placed between if and else statements. It allows us to check for additional conditions.

More than one elsif can be placed between if and else.

Control Flow in Ruby
Lesson 1 of 2