Quirrel4.41.0

types.Class.weakref

Method on every class
weakref(): 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

examples/types/class/weakref.nut
class Foo { x = 1 }
let wr = Foo.weakref()
println("wr.ref() == Foo =", wr.ref() == Foo)
Output:
wr.ref() == Foo = true

See also

weakrefReturns a weak reference to the instance.
refReturns the value this weakref points at, or null once that value is gone.
classclass index