Code: Select all
MsgBox % ">>" ["A", "B", "C"].Count() "<<"
MsgBox % ">>" ["A", "B", "C"].Length() "<<"
Isolated works
Code: Select all
MsgBox % ">>" ( ["A", "B", "C"].Count() ) "<<"
Code: Select all
MsgBox % ">>" ["A", "B", "C"].Count() "<<"
MsgBox % ">>" ["A", "B", "C"].Length() "<<"
Code: Select all
MsgBox % ">>" ( ["A", "B", "C"].Count() ) "<<"
Code: Select all
; MsgBox % ">>" ["A", "B", "C"].Count() "<<" ; not available in 1.1.28.02
MsgBox % ">>" ["A", "B", "C"].Length() "<<" ; doesnt work, returns: <<
arr := ["A", "B", "C"]
MsgBox % ">>" arr.Length() "<<" ; works, returns: >>3<<
MsgBox % ["A", "B", "C"].Length() ; expression, works, returns: 3
MsgBox % ">>" . ["A", "B", "C"].Length() . "<<" ; explicit concat, works, returns: >>3<<
MsgBox % ">>" (["A", "B", "C"].Length()) "<<" ; forced expression/implicit concat, works, returns: >>3<<
Hence, if it is, it isn't. (That is ["A","B","C"] tries to do member access on ">>" which isn't valid)expressions wrote:[v1.0.97+]: Array literal. If the open-bracket is not preceded by a value (or a sub-expression which yields a value), it is interpreted as the beginning of an array literal. For example, [a, b, c] is equivalent to Array(a, b, c)
how so?Helgef wrote:.. tries to do member access on ">>" which isn't valid..
Code: Select all
; https://autohotkey.com/docs/Variables.htm#operators
; https://autohotkey.com/boards/viewtopic.php?f=14&t=49605
; 1.1.28.02 btw if that makes any difference
Arr := {"A": {"B": {"C": "kek"}}}
MsgBox, % "Arr" ["A", "B", "C"] ; supposed member access, returns: blank
MsgBox, % Arr["A", "B", "C"] ; actual member access, returns: kek
; >> := {"A": {"B": {"C": "kek"}}} ; moot, cant declare var '>>'
; MsgBox, % ">>" ["A", "B", "C"] ; moot, cant declare var '>>'
; MsgBox, % >>["A", "B", "C"] ; moot, cant declare var '>>'
Code: Select all
q:: ;get value from object/string
"".base.__get := "f"
Arr := {"A": {"B": {"C": "hey"}}}
MsgBox, % "Arr" ["A", "B", "C"] ;HEY ;surprising
MsgBox, % Arr ["A", "B", "C"] ;hey ;surprising
MsgBox, % "Arr"["A", "B", "C"] ;HEY ;surprising
MsgBox, % Arr["A", "B", "C"] ;hey
return
f()
{
return "HEY"
}
It is invalid because strings have no members by default. As you showed, it can be valid.Helgef wrote:As I said, it is invalid, because you cannot member access a string.
Users browsing this forum: divanebaba and 19 guests