lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>>>>> "Richard" == Richard Green <pslmsngr4lua@gmail.com> writes:

 Richard> 2) Sets -- In page 15 of /Programming in Lua, third edition/
 Richard> you state, "We use tables to represent ordinary arrays,
 Richard> *sets*, records, and ...".  The one thing that I miss from
 Richard> Pascal in modern programming languages is Pascal's set,
 Richard> especially inside an if statement.

A "set" in Lua is simply a table where the keys are the members of the
set and the values are not significant (any true value will do).

current_month = 'Sep'
summer_months = { Jun = true, Jul = true, Aug = true }
if summer_months[current_month] then
  -- stuff
end

-- 
Andrew.