types.Class.tostring
Method on every
classtostring(): any
Converts the class to a string.
Return value
Always "(class : 0x" + address + ")", the VM's generic default. A class cannot customize its own conversion.
Notes
A _tostring method defined in a class body customizes how instances of that class convert to a string (see types.Instance.tostring); it has no effect on the class object itself, since class-level indexing has no delegate lookup for class.tostring() to fall back through. Foo.tostring() and (class)Foo.tostring()-style string concatenation both always show the raw pointer form, whatever Foo defines.
Since the address varies from run to run, examples on this site can only check a fixed prefix of the result, not the full string.
Example
class Foo { x = 1 }
let s = Foo.tostring()
println("s.slice(0, 8) =", s.slice(0, 8))Output:
s.slice(0, 8) = (class :See also
tostring | Converts the instance to a string. |
getmetamethod | Looks up one of the class's metamethods by name, without triggering it. |
| class | class index |