What if you want more than two options, though? It’s elsif to the rescue! The elsif statement can add any number of alternatives to an if/else statement, like so:

if x < y # Assumes x and y are defined puts "x is less than y!" elsif x > y puts "x is greater than y!" else puts "x equals y!" end



Add an elsif block to your if/else statement in the editor.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?