Variables - LieutenantTeaTM/BubbleTea GitHub Wiki
Variables in BubbleTea are defined as:
v
IDENTIFIER
:
TYPE
->
VALUE
;
For example let's create a variable x
.
v x: int -> 5;
We can use x in this scope whenever we want, however if we try to update the variable such as:
v x: int -> 5;
x: 6; // Fails
Variables are constant by default, we need to allow mutability for x
. This is done by prefixing the IDENTIFIER
with &
.
v &x: int -> 5;
x: 6; // Works!
&
is the mutability operator.
If it was not already clear, variables are updated with just a single :
, but only if mutable.