Code: Select all
Arr := []
Arr[2] := "R"
Arr[2, o] := A_TickCount
msgbox % Arr[2, o]
msgbox % arr[2] returns "R" as expected
Code: Select all
Arr := []
Arr[2] := "R"
Arr[2, o] := A_TickCount
msgbox % Arr[2, o]
you assigned here, so the rest failsMulti-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
Arr[2] := "R"
Code: Select all
Arr := []
;Arr[2] := "R"
Arr[2, "o"] := A_TickCount
msgbox % Arr[2, "o"]
Code: Select all
Arr := []
Arr[2] := "R"
Arr[2] := {"o" : A_TickCount}
msgbox % Arr[2, "o"]
Code: Select all
class Box {
__New(material, width, height) {
this.material := material
this.width := width
this.height := height
}
}
CollectionOfBoxes := [{"material" : "cardboard", "width" : 200, "height" : 200}
, {"material" : "wood", "width" : 100, "height" : 500}
, {"material" : "paper", "width" : 400, "height" : 300}]
steelBox := {}
steelBox.material := "steel"
steelBox.width := 50
steelBox.height := 50
CollectionOfBoxes.push(steelBox)
plasticBox := new Box("PET", 200, 250)
CollectionOfBoxes.push(plasticBox)
for index, element in CollectionOfBoxes {
MsgBox, % "ID: " . index
. "`r`n" . "Material: " . element.material
. "`r`n" . "Width: " . element.width
. "`r`n" . "Height: " . element.height
}
fourthBox := CollectionOfBoxes[4]
MsgBox, % "Fourth Box in the collection "
. "`r`n" . "Material: " . CollectionOfBoxes[4].material
. "`r`n" . "Width: " . fourthBox.width
. "`r`n" . "Height: " . CollectionOfBoxes[4, "height"]
Code: Select all
q::
Box := []
Box[1, "material"] := "cardboard"
Box[2, "material"] := "wood"
MsgBox, % Box.2.material
return
jeeswg wrote:It's generally long-winded when you assign it, but simple when you retrieve it.Code: Select all
q:: Box := [] Box[1, "material"] := "cardboard" Box[2, "material"] := "wood" MsgBox, % Box.2.material return
Users browsing this forum: Google [Bot], Spawnova and 273 guests