Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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