Ruby If-Elsif-Else

Ruby IF-ELSIF-ELSE

The Ruby IF-ELSIF-ELSE statement syntax and example.

Ruby IF-ELSIF-ELSE syntax

if condition_v1
	-- Ruby code v1
elsif condition_v2
	-- Ruby code v2
else
	-- Ruby code v3
end

Ruby IF-ELSIF-ELSE example

a = 1
b = 2
if a > b
	puts "A is greater than B"
elsif b > a
	puts "B is greater than A"
else
	puts "A is equal to B"
end

Output

B is greater than A