Quirrel4.41.0

types.Array.tostring

Method on every array
tostring(): any

Returns the default text representation of this array.

Return value

A string of the form (array : 0x...); printing an array (with print or println) shows this same text.

Notes

The returned string embeds this array's memory address, so it differs on every run and must never be printed as is; only its fixed prefix, checked here, is stable. Every built-in type without its own _tostring reports itself this way; see iostream.blob.tostring for the same text on a blob, and for why some types need this method registered explicitly to reach it.

Example

examples/types/array/tostring.nut
let s = [1, 2, 3].tostring();
println("type(s) =", type(s));
println("s.len() > 10:", s.len() > 10);    // the embedded address makes the string long
println("s.slice(0, 7) =", s.slice(0, 7));    // only the fixed prefix is safe to print
Output:
type(s) = string
s.len() > 10: true
s.slice(0, 7) = (array 

See also

totableBuilds a table from the array's elements.
tostringAllows calling .tostring() on blob instances (bypassing _get)
arrayclass index