types.Array.weakref
Method on every
arrayweakref(): any
Returns a weak reference to this array.
Return value
A new weakref value. It does not keep the array alive; once nothing else references the array, the weak reference stops resolving.
Notes
Call ref on the result to get the array back.
Example
let a = [1, 2, 3];
let w = a.weakref();
println("type(w) =", type(w));
println("w.ref() == a:", w.ref() == a); // ref() gets the original array back
println("w.ref().len() =", w.ref().len());Output:
type(w) = weakref
w.ref() == a: true
w.ref().len() = 3See also
ref | Returns the value this weakref points at, or null once that value is gone. |
is_frozen | Reports whether this array reference is frozen. |
| array | class index |