Quirrel4.41.0

types.WeakRef.clone

Method on every weakref
clone(): any

Returns this weakref.

Return value

A value == to this. Cloning an atomic reference type such as weakref has nothing to copy piece by piece, unlike types.Table.clone, which builds a new table.

Notes

Takes no arguments. clone is a keyword, so by default wr.clone() and wr.$clone() do not parse. Call it through a computed index, wr["clone"](), or write clone wr. With #forbid-clone-operator the word is an ordinary identifier and wr.$clone() compiles. See types.Integer.clone.

Example

examples/types/weakref/clone.nut
let wr = {}.weakref()
let wr2 = wr["clone"]()
println("wr2 == wr =", wr2 == wr)
println("type(wr2) =", type(wr2))
Output:
wr2 == wr = true
type(wr2) = weakref

See also

refReturns the value this weakref points at, or null once that value is gone.
cloneReturns a shallow copy of the table.
cloneReturns the integer itself.
weakrefclass index