[Metalua-list] Vararg in match

Fabien Fleutot fleutot at gmail.com
Sat Sep 13 16:30:01 GMT+2 2008


Hi,

I never thought about reusing the vararg on the right-hand side of a match
case, but it makes sense indeed.

For now, the simplest way to do that is to use "==" on the left-hand side,
which forces to match against several patterns simultaneously:

local foo = function(ast)
   match ast with
   | `Id { ... } == x -> print(select("#", unpack(x))) -- or rather
print(#x)
   | _ -> print("2")
   end
end

-- Fabien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.luaforge.net/pipermail/metalua-list/attachments/20080913/9f4c66be/attachment.html


More information about the Metalua-list mailing list