[V2] trick to read Map values as properties
Posted: 08 Jul 2022, 13:39
This hack can be used to be able to read the values of a map object as a property, if somebody prefers this syntax.
I learned this trick from thqby.
Funny fact, if you forget to set the CaseSense to Off, the "property" syntax becomes casesensitive.
I learned this trick from thqby.
Funny fact, if you forget to set the CaseSense to Off, the "property" syntax becomes casesensitive.
Code: Select all
#Requires AutoHotkey v2.0-beta
#SingleInstance force
oMap := Map()
oMap.CaseSense := "Off"
oMap.Set("Red", "ff0000", "Green", "00ff00", "Deep Blue", "0000ff")
oMap.DefineProp('__get', { call: oMap.Get }) ; Trick of thqby
MsgBox('oMap["Red"]:' oMap["Red"] "`noMap.Red:" oMap.red)