Skip to content

Instantly share code, notes, and snippets.

@leegao
Created March 13, 2009 04:40
Show Gist options
  • Save leegao/78432 to your computer and use it in GitHub Desktop.
Save leegao/78432 to your computer and use it in GitHub Desktop.
function switch(t)
t.case = function (self,x, p, com)
local f=self[x] or self.default
if f then
if type(f)=="function" then
f(p, x, com)
else
error("case "..tostring(x).." not a function")
end
end
end
return t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment