Object Patterns with Tables
Constructor Values
Build the scalar values an object constructor would store.
Constructor Values
constructor_values.lua
local id =
local prefix = "user"
local key = prefix .. "-" .. id
local state = "disabled"
if id > 5 then
state = "enabled"
end
print("key=" .. key)
print("state=" .. state)
local id =
local prefix = "user"
local key = prefix .. "-" .. id
local state = "disabled"
if id > 5 then
state = "enabled"
end
print("key=" .. key)
print("state=" .. state)
local id =
local prefix = "user"
local key = prefix .. "-" .. id
local state = "disabled"
if id > 5 then
state = "enabled"
end
print("key=" .. key)
print("state=" .. state)
constructor values
A constructor gathers inputs and derives the fields the object will expose.