Constants
Named constants are declared similar to variables however, instead of =
to defined its value, :
is used.
There are few different categories of constants:
- Values
- Types
- Procedures
Value constants
Named value constants can be a character, string, boolean, or numerical value.
#import "fmt.odin";
TAU :: 6.28;
main :: proc() {
WORLD :: "世界";
fmt.println("Hello", WORLD);
fmt.println("The one true circle constant is", TAU);
CHARACTER_C :: 'c';
}
Type constants
A named type declaration creates a distinct type from its base.
My_Int :: int;
m: My_Int = 123;
// i: int = m; // Error!
j: int = cast(int)m;
Procedure constants
A named constant procedure