Wing Programming Language
Wing Next

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

Introduction to variable personalities

Variable personalities are better explained in their dedicated pages, but for instance:
  • 2 has the string, number, int, and u64 personalities
  • Hello only has the string personality
  • X has the string and char personalities
  • -5.1 has the string, number and float personalities
Each variable can have one or many personalities that define what is possible with them or not.