types.Class.hasindex
Method on every
classTests whether key names a member of the class.
The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing
... from the prose below, not from the signature.Parameters
key | any | the member name to test for |
Return value
true if the class has an own member called key, false otherwise.
Notes
Marked pure. Behaves the same as rawin here: a class has no delegate of its own for indexing to bypass, so there is nothing "hasindex" skips that plain lookup would not. A derived class's inherited members count too, since they are copied into its own member table when the class is declared.
Example
class Foo { x = 1 }
println("Foo.hasindex(\"x\") =", Foo.hasindex("x"))
println("Foo.hasindex(\"y\") =", Foo.hasindex("y"))Output:
Foo.hasindex("x") = true
Foo.hasindex("y") = falseSee also
rawin | Tests whether key names a member of the class. |
rawget | Reads the value stored at key in the class's own member table. |
hasindex | Tests whether key names a field or method reachable on this instance. |
| class | class index |