I'm missing something fundamental when it comes to parameters.
obj = {
name = "hey"
}
function say_name(p,k)
return p.k
end
print(say_name(obj,name)) --doesn't print "hey"
I don't understand why this isn't giving the same output as print(obj.name) i.e. "hey"
Changing the function yields the following cases:
function say_name(p) --works...makes sense to me
return p.name
end
function say_name(p,k) --doesn't work...why does k not work the same as p?
return p.k
end
function say_name(p,name) --works....why tho? isn't name a parameter like k is..?
return p.name
end
Is it cause I'm referencing a table value with a parameter? Is there some rule to this I'm missing?