Unset Variable Representations
- Last UpdatedOct 21, 2022
- 1 minute read
Each new data type supports a String() method that returns a string representing the value of the variable. For example:
|
!X = 2.5 |
$* defines a variable X of type REAL with 2.5 as its numeric value. |
|
!S = !X.String() |
$* will be a variable of type STRING, with the value "2.5". |
UNSET variables of all built-in data types have an unset representation:
|
!X = REAL()! S = !X.String() |
$* yields the string '(the empty string). |
|
!X = BOOLEAN() !S = !X.String() |
$* yields the string " (the empty string). |
|
!X = STRING() !S = !X.String() |
$* yields the string 'Unset'. |
|
!X = ARRAY() !S = !X.String() |
$* yields the string 'ARRAY'. |
Other variable types are system-defined variables. Most of these have adopted the unset string 'Unset'. For example:
|
!X = DIRECTION() !S = !X.String() |
$* yields the string 'Unset'. |
User-defined data types can also provide a String() method. These also support an UNSET representation, and usually adopt the UNSET representation 'Unset'.