|
Rici Lake a écrit :
On 19-Sep-06, at 11:45 AM, Grellier, Thierry wrote:So, I would prefer to be able to write something like (VHDL flavor, and yet another even more disturbing keyword :-) knowing that if elseif... could be reused) style = "native" a = { a = 1, b = { b = 2, c = 1 when style == "native", 2 when style == "rock", 0 else } }I actually like "when" (although i use it with "otherwise" because "else" is already in use).
And I find it clearer, I searched something after the else... Sounds corny. Of course, that's more keywords...
But more Lua like would be: a = { a = 1, b = { b = 2, c = {native = 1, rock = 2}[style] or 0 } }
Argh! WOULD BE! I tried it, and wondered by I had syntax errors...Indeed, it seems a bit strange at first, but it is quite elegant in its simplicity (and no new keyword...).
-- Philippe Lhoste -- (near) Paris -- France -- http://Phi.Lho.free.fr -- -- -- -- -- -- -- -- -- -- -- -- -- --