Skip to content

Wonkey types variant

wonkey:wonkey.types.Variant

Struct Variant#

Variant type.

The 'Variant' type is a primitive type that can be used to 'box' values of any type.

An uninitialized variant will contain a 'null' value (of type Void) until you assign something to it.

A variant is 'true' if it contains any value with a non-void type (including a bool false value!) and 'false' if it is uninitialized and has no (void) type.

Any type of value can be implicitly converted to a variant.

To retrieve the value contained in a variant, you must explicitly cast the variant to the desired type. Note that the cast must specify the exact type of the value already contained in the variant, or a runtime error will occur.

The one exception to this is if the variant contains a class object, in which case you can cast the variant to any valid base class of the object.

Properties
DynamicType Dynamic type of the variant value. (read only)
EnumValue Gets the integer enum value of an enum variant. (read only)
Type Static Type of the variant value. (read only)
Methods
GetArrayElement Gets an element from an array.
GetArrayLength Gets the length of an array.
SetArrayElement Sets an element of an array.