iswritable
Checks if a table is writable (not read-only).
Syntax
iswritable(table: table) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
table | table | The table to check |
Returns
| Type | Description |
|---|---|
boolean | True if the table can be modified |
Description
iswritable checks whether a table can be modified. This is the inverse of isreadonly - it returns true when isreadonly would return false, and vice versa.
Example
local myTable = {value = 123}
print(iswritable(myTable)) -- true
makereadonly(myTable)
print(iswritable(myTable)) -- false
makewritable(myTable)
print(iswritable(myTable)) -- trueMetatable Example
local mt = getrawmetatable(game)
if iswritable(mt) then
print("Metatable is writable")
else
print("Metatable is read-only")
makewritable(mt)
endNotes
- Equivalent to
not isreadonly(table) - Useful for checking before modifications
Related Functions
isreadonly- Check if table is read-onlymakewritable- Make table writablemakereadonly- Make table read-only