Variables
Last updated
Last updated
A variable can hold a value. Variables are by default immutable to prevent from changing the value. If you want to change the value later you can declare the variable as mutable with mut
.
The syntatic structure of a variable definition:
Sample of a variable definition:
Back can automaticly deduce the type of the variable but if you want to specify the type, here is how:
You can also specify the type by a literal type specifier:
A list of all basic primitive datatypes can be found .
You can only assign mutable variables. If you try to change an immutable variable the compiler throws an error.
The syntactic structure of assignments:
A simple example: