I am trying to get this to work but I am not sure if Lua supports this kind of variables
function newUser(accountName, password)
accountName = accountName
password = password
end
testUser = newUser("testName" , "testPassword")
print(testUser.password)
Does the testUser.password
work with Lua?
newUser
is a function, so testUser
gets the function's return value, that is, nothing. A simple and direct way to fix the problem is to return a table:
function newUser(accountName, password)
local t = {}
t.accountName = accountName
t.password = password
return t
end
EDIT: Or better, following your style as @lhf suggested:
function newUser(accountName, password)
return { accountName = accountName, password = password }
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With