Variable Scoping
Currently the language provides scoping on the global and the local level, meaning there are two type of scoped varibles:
- Global
- Local
In the local scope there are two types of variables which can be used
- Function Local Variables
- Function Argument Variables
Global Variables
int i = 100;
double j = 10.99999;
bool b = true;
fn start() void {
return;
}
Local Variables
fn start() void {
int i = 100;
double j = 10.99999;
bool b = true;
return;
}
Function Arguments
fn examplefunc(int a,double b,bool c) void {
return;
}
note
Refer to Functions section of the Language Reference to know more about functions
Variable Overshdowing
As per scoping, j
will be equal to 100
int i = 10;
fn start() void {
int i = 100;
int j = i;
return;
}