Quirrel4.41.0

types.Table.is_frozen

Method on every table
is_frozen(): any

Reports whether this reference to the table was frozen with freeze().

Return value

true if the table is immutable, false otherwise.

Notes

Takes no arguments. Checks the table itself, not what it contains: freezing a table freezes only its own slots, so is_frozen() on a table holding a mutable nested table still reports true for the outer one while the inner one stays freely editable.

clone never copies the flag: cloning a frozen table gives back a table for which is_frozen() is false.

Example

examples/types/table/is_frozen.nut
let t = {a=1, inner={x=1}}
println("t.is_frozen() =", t.is_frozen())

let frozen = freeze(t)
println("frozen.is_frozen() =", frozen.is_frozen())
println("frozen == t:", frozen == t)              // freeze() marks the same table, no copy
println("t.inner.is_frozen() =", t.inner.is_frozen())      // freezing is shallow: inner is untouched

t.inner.x = 2                     // still writable
println("t.inner.x =", t.inner.x)
Output:
t.is_frozen() = false
frozen.is_frozen() = true
frozen == t: true
t.inner.is_frozen() = false
t.inner.x = 2

See also

cloneReturns a shallow copy of the table.
weakrefReturns a weak reference to the table.
clearRemoves every key/value pair from the table, in place.
tableclass index