[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Fwd: Re: new thought experiment: what would you add to Lua ?
- From: Andrew Gierth <andrew@...>
- Date: Sat, 15 Sep 2018 16:33:33 +0100
>>>>> "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.