我一直在使用这个元表一个小时,而这个错误是最难修复的错误:
local Check = {
InvitedMembers = {
John = "Allowed",
Mary = "Allowed",
Halley = "Allowed"
}
}
local Filter = {
__index = function(t,k)
for i ,v in pairs(t.InvitedMembers) do
if i ~= k then
error("You're not invited by us")
elseif i == k then
return "This way"
end
end
end
}
local ConnectFilter = setmetatable(Check,Filter)
print(Check.InvitedMembers.Sans)
我试图进行过滤,但是此代码返回了nil
值。
您的代码中有两个错误: