Quirrel4.41.0

types.Integer.clone

Method on every integer
clone(): 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

examples/types/integer/clone.nut
// 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 = true

See also

cloneReturns the float itself.
cloneReturns the bool itself.
cloneReturns a shallow copy of the table.
weakrefReturns the integer itself.
integerclass index