Consider the Lua code below:
local util = {}
function util:foo(p)
print (p or "p is nil")
end
util.foo("Hello World")
util.foo(nil, "Hello World")
When I run this in lua console, I get following result:
p is nil
Hello World
Can somebody explain this behavior to me.
Edit I got the code working by making following change:
local util = {}
function util.foo(p)
print (p or "p is nil")
end
util.foo("Hello World")
util.foo(nil, "Hello World")
I am fairly new to Lua, so any pointers/links explaining this behavior will be appreciated.