Skip to content

Instantly share code, notes, and snippets.

@ponzao
Created January 24, 2011 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponzao/793266 to your computer and use it in GitHub Desktop.
Save ponzao/793266 to your computer and use it in GitHub Desktop.
function dispatch(t)
return function(k)
if t[k] then t[k]() end
end
end
local dispatcher = dispatch({ f = function()
print("f")
end,
g = function()
print("g")
end
})
dispatcher("f") --> f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment