[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Switch/Case statements revisited (using tables?)
- From: Tim Johnson <tim@...>
- Date: Wed, 7 Nov 2007 11:32:33 -0800
On Wednesday 07 November 2007, Javier Guerra wrote:
> sure, i do this all the time (and i'm sure many others).
>
> also, since in Lua functions are really anonymous (unlike Python), it
> doesn't pollute any namespace (the table itself is the namespace)
>
>
> -- easy to write...
> local dispatch = {
> start = function (x) .... end,
> continue = function (x) ..... end,
> .....
> }
>
> dispatch[state](x) -- and easy to call!
Bingo!
Thanks
tj