vec/map Expression
GLuaX provides concise syntax for initializing vectors and maps. You can optionally specify type parameters using ::<type>.
Note: The syntax for initializing a vector or map looks very similar to class initialization in GLuaX. The difference is that the compiler detects when you are initializing a
maporvecand parses it differently.
Tip: It is recommended to write the curly braces directly after
maporvec(e.g.,map{...}orvec{...}), and not with a space likemap {...}. This helps visually and syntactically distinguish map/vector initialization from class initialization.
Vector Initialization
Section titled “Vector Initialization”A vector can be initialized with a list of values:
vec{1, 2, 3}You can also specify the element type explicitly:
vec::<number>{1, 2, 3}Map Initialization
Section titled “Map Initialization”A map is initialized with key-value pairs using curly braces and colons:
map{ 1: 1, 2: 2,}You can optionally specify the key and value types:
map::<number>{ 1: 1, 2: 2,}
map::<number, number>{ 1: 1, 2: 2,}Example Usage
Section titled “Example Usage”let numbers = vec{1, 2, 3};let mapping = map{ 1: "one", 2: "two", 3: "three",};