mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 10:55:48 +01:00
994 B
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!iffruit.IsYellow()isTrue. - Print
Orange!iffruit.IsYellow()isFalseandfruit.IsOrange()isTrue. - Print
Vegetable!if both of the above returnFalse.
TODO: Flesh out text (currently just overview)
Relevant proposals
Most discussion of design choices and alternatives may be found in relevant proposals.