Appearance
Maps
There is no difference in terms of behavior between GreyScript and MiniScript.
The final basic data type in MiniScript is the map. A map is a set of key-value pairs, where each unique key maps to some value. In some programming environments, this same concept is called a dictionary.
Source: MiniScript manual
Operations
gs
// concatenation
a = { "test": 1 } + { "foo": "bar" } // merges two maps into one - results in {"test":1,"foo":"bar"}
// equality
a = { "test": 1 } == { "test": 1 } // returns true (1) if two maps are equal otherwise false (0) - results in true (1)
// inequality
a = { "test": 1 } != { "test": 1 } // returns true (1) if two maps are inequal otherwise false (0) - results in false (0)
// index
a = a["test"] // get value of key - results in 1
// dot index
a = a.foo // get value of key - results in "bar"
Isa
Beside of using typeof, to determine if a variable is a map, you can also use isa.
gs
myVariable = {}
print(myVariable isa map) // prints 1
Extend type
It is possible to extend your own methods to the map type.
gs
map.toString = function
return str(self)
end function
print(({ "test": 123 }).toString()) // prints {"test":123}