Created
May 16, 2012 08:28
-
-
Save joehakimrahme/2708699 to your computer and use it in GitHub Desktop.
Switch table in Lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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