types/optional.ql
An entity that may either hold a value or be empty. The value being held may be anything.
| Constructor | Description |
|---|---|
| Optional(_value, _hasValue) | Creates a new optional with the given value and if it has a value. It is strongly recommended to just use |
| Function | Description |
|---|---|
| static fun fromValue(value) | Creates an optional from a value. |
| static fun fromEmpty() | Creates an empty optional. |
| fun hasValue() | Checks if the optional has a value. |
| fun getValue() | Gets the value of the optional. This will stop the program if the optional is empty, so check first via hasValue(). |
| fun clearValue() | Clears the value of the optional. |
| fun setValue(value) | Sets the value of the optional. |
| fun toString() |
| Field | Description |
|---|---|
| any _value | The value of the optional. |
| boolean _hasValue | If the optional has a value. |
Creates a new optional with the given value and if it has a value. It is strongly recommended to just use fromValue() or fromEmpty()
Creates an optional from a value.
value
|
The value to create the optional from. This may be any type |
The optional created from the value
Gets the value of the optional. This will stop the program if the optional is empty, so check first via hasValue().
The value of the optional, any type
Clears the value of the optional.
<No description provided>