types.Integer.clone
Method on every
integerclone(): any
Returns the integer itself.
Return value
this, unchanged. An integer has no identity separate from its value, so there is nothing a copy could do differently from returning the same value - unlike types.Table.clone, which allocates a new table.
Notes
Takes no arguments. clone is a keyword as well as a method name, so by default (5).clone() and (5).$clone() do not parse: the compiler reads clone after a dot as the keyword, not a field name. Write clone 5, or call through a computed index, x["clone"](), to reach the method directly. With #forbid-clone-operator the word is an ordinary identifier and x.$clone() compiles. See types.Table.clone.
Example
// clone is a keyword, so a literal receiver needs the operator form...
println("clone 5 =", clone 5)
// ...or bracket indexing, which calls the method without going through
// the keyword-sensitive dot grammar.
let x = 5
println("x[\"clone\"]() =", x["clone"]())
println("x[\"clone\"]() == x =", x["clone"]() == x)Output:
clone 5 = 5
x["clone"]() = 5
x["clone"]() == x = trueSee also
clone | Returns the float itself. |
clone | Returns the bool itself. |
clone | Returns a shallow copy of the table. |
weakref | Returns the integer itself. |
| integer | class index |