lua-users home
lua-l archive

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

on 11/9/07 1:41 AM, steve donovan at wrote:

> My vote is for David Given's suggestion:
> match k
>   with 10, 11 then return 1 end
>   with 12 then return 2 end
>   with i if 13<=i and i<=16 then return 4 end
> end

The English would probably read better with "on" and "do" instead of "with"
and "then".

I'm not sure what the last clause means unless it's:

    if k == i and 13 <= i and i <= 16 then ...

which is an interesting extension to standard case behavior. On the other
hand, it then forces sequential testing rather than simply accepting that as
one implementation.

But I find myself missing switch/case statements relatively rarely.