From: Andrew Gierth <andrew@tao11.riddles.org.uk>
Subject: Re: Fwd: Re: new thought experiment: what would you add to
Lua ?
To: Richard Green <pslmsngr4lua@gmail.com>
Cc: lua-l@lists.lua.org
Message-ID: <87d0telr22.fsf@news-spur.riddles.org.uk>
Content-Type: text/plain; charset=utf-8
"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.