Variables are like containers in which values can be inserted or changed.
variable defining:
var name [: type [= value]]
name
: your variable name
NOTE: names should not start with a number, By compiling this code, you will receive an error:
var 6Apple : int
type
: your variable typevalue
: your variable value
example :
var myvar : string
var my_var : int
var _myvar : float
Do the following to give a value to the variable :
name = value
example :
var x : int
x = 14
You can not assign a value to a variable as opposed to the original type ,this code have error :
var myInt : int
myint = 1.1 # error
Constant(const) is a type qualifier a keyword applied to a data type that indicates that the data is read only(wikipedia).
for example :
const MyConst = "MyName" # or : let MyConst = "MyName"
print(MyConst) # output : MyName
NOTE: You cannot change the const values. for example (compiler return an error):
const PI = 3.14 # or : let PI = 3.14
PI = 3.1415 # error