Documentation wrote:Multi-dimensional assignments such as table[a, b, c, d] := value are handled as follows:
- If there is only one key remaining, perform the assignment and return. Otherwise:
- Search the object for the first key in the list.
- If a non-object is found, fail.
- If an object is not found, create one and store it.
- Recursively invoke the sub-object, passing the remaining keys and value - repeat from the top.
Code: Select all
class baseObj {
__Get(params*) {
OutputDebug, " Get():"
for each, param in params
OutputDebug, % " p[" each "] = " param
}
__Set(params*) {
OutputDebug, " Set():"
for each, param in params
OutputDebug, % " p[" each "] = " param
ObjInsert(this, params[1], {base: baseObj})
}
__Call(params*) {
OutputDebug, " Call():"
for each, param in params
OutputDebug, % " p[" each "] = " param
}
}
;~ a := {base: baseObj}
;~ ;a.b[c] => a["b", c]
;~ a.b := {}
;~ a["b", c] := 4
;~ ; no meta-function is called
a := {base: baseObj}
;a.b[c] => a["b", c]
a.b := {base: baseObj}
a["b", c] := 4
; __Set called with two parameters: c and 4
- Recursively invoke the sub-object, passing the remaining keys and value - repeat from the top.