top of page
Variables
Variables can be directly be assigned values and the type can be inferred based on that
x = 5
​
This variable is now in global scope.
If there is a function such as
​
def setX value = (x = value)
​
then the value of x will be modified in global scope as well.
To create a local variable you can declare the type of the variable
​
def setX value = (int x = value)
​
or use the the var keyword.
​
def setX value = (var x = value)
​
You can also declare a variable with a default value
​
int x
​
Here x will be local variable assigned to 0.
​
Similarly the following types will have the following default values
-
int : 0
-
float : 0.0
-
list/string : []
-
tuple : {}
-
char : 'a'
bottom of page