我在lua中遇到table.remove命令的问题,它没有显示任何错误,但它只是没有删除任何内容。
name = { "Patricia", "Linda", "Barbara", "Elizabeth", "Jennifer", "Maria"}
surname = { "McKechnie", "Musto", "Wheeler", "Bozeman", "Johnson", "Mason"}
usernames = { "Liall196466", "Therommover69", "Hinquallysx", "Wheinesxx", "Hationers77kt", "Andiedxxx"}
passwords = { "password", "password", "password", "password", "password", "password"}
for i=1,5,1
do
table.remove(name, 1)
table.remove(surname, 1)
table.remove(usernames, 1)
table.remove(passwords, 1)
end
答案 0 :(得分:1)
你没有表明在表中仍然是:
local function tprint(t)
for k,v in pairs(t) do print(k,v) end
end
tprint(name)
tprint(surname)
tprint(usernames)
tprint(passwords)
我的输出:
1 Maria
1 Mason
1 Andiedxxx
1 password