May 2017
Intermediate to advanced
416 pages
21h 33m
English
Sets are commonly used for lookup tables, and because we can use hashkeys as indexes in Lua, lookups are executed in constant time and very efficiently:
set={} items = { "2013-02-01", "2013-02-02", "2013-02-03" } for _, key in pairs(items) doset[key]=true end --To look up a key, we simply access the field. if set["2013-02-01"] then print("Record found.") end
Read now
Unlock full access