Difference between revisions of "Table.freeze"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2022.3<br/> '''Class:''' table<br/> === Description === This function makes the given table read-only, effectively "freezing" it...")
 
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
This function makes the given table read-only, effectively "freezing" it in its current state. Attempting to modify a frozen table throws an error.
 
This function makes the given table read-only, effectively "freezing" it in its current state. Attempting to modify a frozen table throws an error.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(table) = table.freeze(t)
 
(table) = table.freeze(t)
 
</source>
 
</source>

Revision as of 15:31, 13 July 2023

Available since: Gideros 2022.3
Class: table

Description

This function makes the given table read-only, effectively "freezing" it in its current state. Attempting to modify a frozen table throws an error. <syntaxhighlight lang="lua"> (table) = table.freeze(t) </source>

This freezing effect is shallow, which means that you can write to a table within a frozen table. To deep freeze a table, call this function recursively on all of the descending tables

Parameters

t: (table) table to freeze

Return values

Returns (table) the frozen table