Quirrel4.41.0

getroottable

Global, available without an import
getroottable(): table

Returns the root table.

Return value

The root table itself, the same object that is available using :: operator. ::foo is equivalent to getroottable()["foo"].

Example

examples/globals/getroottable.nut
::GLOBAL_VAR <- 1
getroottable().GLOBAL_VAR = 2
println("::GLOBAL_VAR =", ::GLOBAL_VAR)   // a write through getroottable() reaches the real global

getroottable().NEW_ONE <- 3
println("::NEW_ONE =", ::NEW_ONE)       // new slots too

println("getroottable() == getroottable() =", getroottable() == getroottable())  // the same table every call
Output:
::GLOBAL_VAR = 2
::NEW_ONE = 3
getroottable() == getroottable() = true

See also

getconsttableReturns the const table.
compilestringCompiles source into a callable closure, without running it.
globalsmodule index