types.Class.weakref
Method on every
classweakref(): any
Returns a weak reference to the class.
Return value
A weakref value. Its ref() method gives back this same class object as long as something else still keeps it alive, or null once it has been collected.
Notes
Holding a weak reference to a class does not keep it, or the instances still pointing at it as their getclass(), alive.
Example
class Foo { x = 1 }
let wr = Foo.weakref()
println("wr.ref() == Foo =", wr.ref() == Foo)Output:
wr.ref() == Foo = trueSee also
weakref | Returns a weak reference to the instance. |
ref | Returns the value this weakref points at, or null once that value is gone. |
| class | class index |