92c5cd59f5
- Create stdlib/Std/Io.bux with extern func declarations
- Rename C shim functions to short names (PrintLine, PrintInt, etc.)
- Update all 9 examples to use import Std::Io::{PrintLine, PrintInt};
- Remove manual extern func Std_Io_* declarations from examples
35 lines
574 B
Plaintext
35 lines
574 B
Plaintext
// Enums - Enumeration types
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
|
|
enum Color {
|
|
Red,
|
|
Green,
|
|
Blue
|
|
}
|
|
|
|
func ColorName(c: Color) -> String {
|
|
if c == Color::Red {
|
|
return "Red";
|
|
}
|
|
if c == Color::Green {
|
|
return "Green";
|
|
}
|
|
if c == Color::Blue {
|
|
return "Blue";
|
|
}
|
|
return "Unknown";
|
|
}
|
|
|
|
func Main() -> int {
|
|
let myColor: Color = Color::Green;
|
|
|
|
PrintLine("My color is:");
|
|
PrintLine(ColorName(myColor));
|
|
PrintLine("Color value:");
|
|
PrintInt(myColor as int);
|
|
PrintLine("");
|
|
|
|
return 0;
|
|
}
|