我正试图在个人时间为“银行”类型的东西创建一个基本的帐户创建者,我遇到了一个问题。我创建了一个名为“newAccount”的文件,用于创建新帐户,但是当我运行它时,它只询问第一个问题,然后它就会停止工作。
这是我到目前为止所拥有的。
print("What is the user's name?")
name = read()
file = io.open(name ,"w")
file:write(1, "Name: " + name, "\n")
print("What do they owe?")
owe = read()
file:write(2, "Owe: " + owe, "\n")
print("What is their account balance?")
balance = read()
file:write(3, "Balance: " + balance, "\n")
file:close(name)
停止运行后,它说:
newAccount:4: attempt to perform arithmetic __add on string and string
App has finished, press any key to exit."
答案 0 :(得分:2)
Lua使用..
来连接字符串,而不是+
。变化
"Name: " + name
到
"Name: " .. name