Metatables

setreadonly

Sets whether a table is readonly and returns no values.

Syntax

setreadonly(target: table, readonly: boolean)

Arguments

NameTypeDescription
targettableTable whose readonly status is changed.
readonlybooleanBoolean readonly value to apply.

Description

Sets whether a table is readonly and returns no values.

Call it with 2 parameter(s): target, readonly. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Set a table's readonly flag to a specific boolean value.

local target = {}

setreadonly(target, true)
print(isreadonly(target))

setreadonly(target, false)
print(isreadonly(target))