Section 4.3

elseif statement


  • How does elseif work?
  • Programming for efficiency.
  • When to use an else vs elseif.

How does elseif work?

elseif does essentially the same thing as if statement.

  • Has it’s own condition (not tied directly to if statement)
  • It can also have multiple conditions
  • Does NOT execute if a previous if/elseif has returned true
  • Terminated by a single end

Programming for efficiency

Allows for a more efficient program flow
Links separate if-end statements together

When to use an else vs elseif