tlhopha
Compares one value against many options and runs the branch that matches.
Use tlhopha when a single value has to branch many ways — the same job as a chain of fa … gongwe, but easier to read. The value is compared against each tsela with strict equality (===), so 1 and "1" do not match. End each branch with kgaola; if you do not, execution falls through into the branch below. tlwaelo runs when nothing matched.
Syntax
Section titled “Syntax”tlhopha (boleng) { tsela A: ... kgaola; tlwaelo: ... }Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 200);
bokamorago(220);
gopheta (diri i = 0; i < 4; i = i + 1) {
tlhopha (i) {
tsela 0:
tlatsaMmala(220, 60, 60);
kgaola;
tsela 1:
tlatsaMmala(60, 180, 90);
kgaola;
tsela 2:
tlatsaMmala(60, 110, 220);
kgaola;
tlwaelo:
tlatsaMmala(150);
}
thalaKhutlonne(i * 96 + 26, 60, 72, 72);
}
}