28 lines
569 B
Plaintext
28 lines
569 B
Plaintext
// With explicit values
|
|
library FruitsKind type BasicLibrary {}
|
|
const APPLE int = 0;
|
|
const BANANA int = 1;
|
|
const CHERRY int = 2;
|
|
end
|
|
|
|
program EnumerationTest
|
|
|
|
function main()
|
|
whatFruitAmI(FruitsKind.CHERRY);
|
|
end
|
|
|
|
function whatFruitAmI(fruit int in)
|
|
case (fruit)
|
|
when(FruitsKind.APPLE)
|
|
syslib.writestdout("You're an apple.");
|
|
when(FruitsKind.BANANA)
|
|
syslib.writestdout("You're a banana.");
|
|
when(FruitsKind.CHERRY)
|
|
syslib.writestdout("You're a cherry.");
|
|
otherwise
|
|
syslib.writestdout("I'm not sure what you are.");
|
|
end
|
|
end
|
|
|
|
end
|