types.WeakRef.tostring
Method on every
weakreftostring(): any
Returns a string naming the type and identity of this weakref object itself - not of the value it points at.
Return value
A string shaped like (weakref : 0x...), the same generic format types.Table.tostring uses, since weakref has no _tostring metamethod of its own to override it.
Errors
The address in the result changes from run to run and between processes: never compare or print it verbatim in code whose output must stay stable, only match against the fixed part of the string, such as s.indexof("weakref") != null.
Notes
Takes no arguments. To see the pointed-to value's own string form instead, dereference first: wr.ref().tostring().
Example
let wr = {}.weakref()
let s = wr.tostring()
// format is "(weakref : 0x...)" - compare instead of printing the address
println("s.indexof(\"weakref\") != null =", s.indexof("weakref") != null)
println("type(s) =", type(s))Output:
s.indexof("weakref") != null = true
type(s) = stringSee also
ref | Returns the value this weakref points at, or null once that value is gone. |
tostring | Returns a string that names the type and identity of the table. |
tostring | Converts the integer to its decimal string form. |
| weakref | class index |