Stenway Developer Network

else Keyword

Else

If / else:

if i == 0
  methodA()
else
  methodB()
end

Else if

if i == 0
  methodA()
else if i == 1
  methodB()
else
  methodC()
end

Single-line statements can be shortened to:

if i == 0 : methodA()
else : methodB()

Or mixed:

if i == 0 : methodA()
else if i == 1 : methodB()
else
  methodC1()
  methodC2()
end