in v1, the get metafunction is invoked whenever an object's key that doesnt exist is attempted to be accessed(ie
myObj.nonexistent_key or
myObj["nonexistent_key"])
and one of that object's
bases defines such a meta function, which is why the additional object is required there. the meta-get property must contain a Func Reference or a BoundFunc Reference, so
Func("Abs").Bind(0) spares u having to write:
Code: Select all
this_func_name_is_now_taken(Args*) {
return 0
}
u can port it like so:
Code: Select all
#Requires AutoHotkey v2.0-a129-78d2aa15
l_arr := {base: {__Get: (*) => 0}}
but that doesnt mean its going to do what u want it to do(but since u dont know what u want it to do..., u can see how thats a bit of a predicament)
in v2, meta-get can be defined and called on the object itself, too, so it might be possible that u dont actually need the extra base object
in v2, meta-get is called when nonexistent properties are accessed(ie
myObj.nonexistent_prop and
myObj.%'nonexistent_prop'%), which is different in the case of the indexing operator(which is handled by
__Item)
lastly, as the name of ur variable suggests, u might actually not need an
object but an
Array