Quirrel4.41.0

types.Thread.clone

Method on every thread
clone(): any

Returns the thread itself: a thread has no separate clone identity.

Return value

The same thread clone was called on - clone t == t is always true, whatever state t is in.

Notes

clone is a keyword as well as a method name, so by default t.clone() and t.$clone() do not parse. Use the bracket form, t["clone"](), or the operator form, clone t. Both reach this same method. With #forbid-clone-operator the word is an ordinary identifier and t.$clone() compiles.

Example

examples/types/thread/clone.nut
function body() { suspend() }
let t = newthread(body)
println("clone t == t =", clone t == t)
println("t[\"clone\"]() == t =", t["clone"]() == t)
Output:
clone t == t = true
t["clone"]() == t = true

See also

weakrefReturns a weak reference to the thread.
cloneReturns the closure itself: unlike a table, array or class instance, a closure has no separate clone identity.
threadclass index