Skip to content

Instantly share code, notes, and snippets.

@joehakimrahme
Created May 16, 2012 08:28
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 joehakimrahme/2708699 to your computer and use it in GitHub Desktop.
Save joehakimrahme/2708699 to your computer and use it in GitHub Desktop.
Switch table in Lua
abs = function(x)
test = {
[true]=-x,
[x>0]=x,
[x==0]=0}
return test[true]
end
print (abs(-3)) -- outputs "3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment