Assigning variables
Variables are like boxes that store a specific value that you can retrieve at any time throughout your code. Variables can have one or more personalities, and are set simply from their name and the corresponding values.
All variables in Wing start with
$
and are assigned with an equal sign, like this:$variable = Value
Variables, by default, are not constant, it is therefore possible to reassign a variable that has already been assigned, like this:
$variable = Value
$variable = Other value -- This will work
Notice how there is no need to indicate the "type" of the variable. This is because Wing does not work with types, but with variable personalities.
In cases where you don't want a variable's value to change, you can make it constant. This is done by adding an exclamation mark at the end of the variable name when assigning it:
$variable! = Value
$variable = Other value -- This will give an error
If you want to make a non-constant variable constant, you can use the following code:
$oldvariable! = $oldvariable
$oldvariable = Hello -- This will give an error
2
has thestring
,number
,int
, andu64
personalitiesHello
only has thestring
personalityX
has thestring
andchar
personalities-5.1
has thestring
,number
andfloat
personalities
Each variable can have one or many personalities that define what is possible with them or not.