- In AHK v1 this creates 2 keys, in AHK v2 this creates 1 key.
Code: Select all
obj := {}
obj[1] := "a"
obj["1"] := "b"
- Although there may be workarounds (e.g. prefixing keys with a character for when you want to sort numbers/strings as strings), if there is not *some* way to do this, this would be a fundamental reduction in the general power of AutoHotkey objects.
- I know that for example when dealing with Explorer objects, sometimes you want to refer to item 123 (the 124th item), and sometimes you want to refer to a folder called '123'. So there may be important scenarios in AutoHotkey, where at least having a way to do this would be beneficial.
Code: Select all
q::
oArray := Object(1, "a", "1", "b")
vOutput := ""
for vKey, vValue in oArray
vOutput .= vKey " " vValue "`r`n"
MsgBox(vOutput)
;MsgBox, % vOutput
return
;AHK v1
;1 a
;1 b
;AHK v2
;1 b
detect/Remove duplicate values in array - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13#p181713
Some relevant information from the documentation:
Objects
https://autohotkey.com/docs/Objects.htm
Objects•Integer keys are stored using the native signed integer type. AutoHotkey 32-bit supports integer keys in the range -2147483648 to 2147483647. AutoHotkey supports 64-bit integers, but only AutoHotkey 64-bit supports the full range as keys in an object.
https://lexikos.github.io/v2/docs/Objects.htm
Thank you for reading.•Integer keys are stored using the native signed integer type where possible. Integers which are less than -2147483648 or greater than 2147483647 are stored as strings on AutoHotkey 32-bit but as integers on AutoHotkey 64-bit. (By contrast, 64-bit integers can be stored as values on either version.)