- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 9
 
Variable Declaration Statement
Variables are usually declared using the variable declaration statement.
In order to declare one, you specify a name for the variable followed by it's type
my_variable Type
The newly declared variable can immediately be assigned a value by using = followed by a value
total_wins int = 21
Variables can be made strictly-immutable by prefixing their declaration with const
const pi double = 3.14159265
Variables declared as const, cannot have their address taken or be assigned new values
Variables can have their value persist between calls by declaring them as static
import basics
func main {
    repeat 3, print(getNextInteger())
}
func getNextInteger() int {
    static next int = 1
    return next++
}
1
2
3
Static variables that have a __defer__ method will have it called when the program exits.
Multiple variables can be declared at one, by separating the variable names with commas
x, y, z float = 0.0f
Although multiple variables can be declared on the same line, they all must share an initial value
By default, variables are zero-initialized. If this behavior is undesired, you can set the initial value to undef in order to leave the memory uninitialized
not_used_yet double = undef
Variables that are marked as POD (plain-old-data), are immune to __defer__ management procedures.
manual_string POD String = "Hello World"
See POD variables for more information.