To evaluate a variable by itself, just enter the name of the variable. This will return the value of the variable. You can use a variable anywhere you would normally use a number or string. In addition, variables are necessary when defining functions that take arguments (see the section called “Defining Functions”).
You can use Tab completion to get Genius to complete variable names for you. Try typing the first few letters of the name and pressing
The names of variables are case sensitive. That means that variables named
Hello are all different variables.
<identifier> = <value> <identifier> := <value>
x = 3 x := 3
To assign a value to a variable, use the
:= operators. These operators set the value of the variable and return the value you set, so you can do things like
a = b = 5
This will set
b to 5 and then also set
a to 5.
:= operators can both be used to set variables. The difference between them is that the
:= operator always acts as an assignment operator, whereas the
= operator may be interpreted as testing for equality when used in a context where a Boolean expression is expected.
For more information about the scope of variables, that is when are what variables visible, see the section called “Global Variables and Scope of Variables”.
GEL has a number of built-in ‘variables’, such as
GoldenRatio. These are widely used constants with a preset value, and
they cannot be assigned new values.
There are a number of other built-in variables.
See the section called “Constants” for a full list. Note that
i is not by default
the square root of negative one (the imaginary number), and is undefined to allow its use as a counter. If you wish to write the imaginary number you need to