conditionals.md 994 B

Control flow

Table of contents

Overview

if and else provide conditional execution of statements. For example:

if (fruit.IsYellow()) {
  Print("Banana!");
} else if (fruit.IsOrange()) {
  Print("Orange!");
} else {
  Print("Vegetable!");
}

This code will:

  • Print Banana! if fruit.IsYellow() is True.
  • Print Orange! if fruit.IsYellow() is False and fruit.IsOrange() is True.
  • Print Vegetable! if both of the above return False.

TODO: Flesh out text (currently just overview)

Relevant proposals

Most discussion of design choices and alternatives may be found in relevant proposals.