AHK v2: question about enumerating
Posted: 10 Dec 2018, 13:20
1.
R there new ways in AHK v2 to distinguish between [] and {} types of user-created objects?
so knowing which array type the object is, I would serialize it (convert to json-like exportable string)
as a simple non-associative array
["word1","word2", "word3"]
or as pairs "key":value
{"1":"word1","2":"word2","4":"word3"}
depending on the type.
But browsing thru every object's element for that seems suboptimal. Type(object) says just "Object" for both {} and [] created arrays.
2.
And second question is there a way to distinguish between built-in objects like File, BoundFunc, etc and user-created ones which return a class name with Type(object)?
object.HasKey(__Class) or object.__Class or object.IsBuiltin throws an exception "Unknown property" when accessing built-in objects
R there new ways in AHK v2 to distinguish between [] and {} types of user-created objects?
Code: Select all
a:=0
for i in object ;throws exc here if its not an object or doesn't have _NewEnum() method.
if(!(a:=i=A_Index)) ;a=0:associative (have pairs "key":value) or sparse array ([1,,3])
break
as a simple non-associative array
["word1","word2", "word3"]
or as pairs "key":value
{"1":"word1","2":"word2","4":"word3"}
depending on the type.
But browsing thru every object's element for that seems suboptimal. Type(object) says just "Object" for both {} and [] created arrays.
2.
And second question is there a way to distinguish between built-in objects like File, BoundFunc, etc and user-created ones which return a class name with Type(object)?
object.HasKey(__Class) or object.__Class or object.IsBuiltin throws an exception "Unknown property" when accessing built-in objects