[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The meaning of 'sugar' [Forked from Re: Why do we have ipairs?]
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 13 Jun 2014 13:11:30 -0300
> I guess I do not understand what you mean by your above comments, sorry. :(
Bad code:
if x == 43 then ...
elseif x == 67 then ...
...
end
Good code:
-- This is somewhere in your code (probably near the top)
-- Code for Events
MOUSECLICK = 43
KEYPRESS = 67
...
-- this is somewhere else
if x == MOUSECLICK then ...
elseif x == KEYPRESS then ...
...
end
(If everything is in the same module, you can declare those names as
locals.)
-- Roberto