types.Generator.clone
Method on every
generatorclone(): any
Returns the generator itself: a generator has no separate clone identity.
Return value
The same generator clone was called on - clone g == g is always true, whatever state g is in.
Notes
clone is a keyword as well as a method name, so by default g.clone() and g.$clone() do not parse. Use the bracket form, g["clone"](), or the operator form, clone g. Both reach this same method. With #forbid-clone-operator the word is an ordinary identifier and g.$clone() compiles.
Example
function geny() { yield 1 }
let g = geny()
println("clone g == g =", clone g == g)
println("g[\"clone\"]() == g =", g["clone"]() == g)Output:
clone g == g = true
g["clone"]() == g = trueSee also
weakref | Returns a weak reference to the generator. |
clone | Returns the closure itself: unlike a table, array or class instance, a closure has no separate clone identity. |
| generator | class index |