lua 语言 - 尝试调用全局

lua language - attempt to call global

我有 2 个数组 classMate 和 winners,需要检查 classMate 中是否有 winners,如果是,则将 res[i] = 1

function win(classMates , winners)
    res = {}
    for i=1,#winners do
        for j=1,#classMates do
        print(3)
            if winners[i] == classMates[j] then res[i] = 1 else res[i] = 0 end
            print(res)
        end
    end

end
classMates = {"frank" , "alex" , "soli"}
winners = {"lora" , "frank" , "sandra" ,"alex"}
print(winners(classMates,winners))

但是当我这样做时出现错误: 我使用 REPL lua

lua: [string "<eval>"]:15: attempt to call global 'winners' (a table value)

堆栈回溯: [string ""]:15: 在主块中

有什么帮助吗?

块引用

-- not print(winners)
-- cause winners is a table
-- instead
win({"frank" , "alex" , "soli"}, {"lora" , "frank" , "sandra" ,"alex"})
-- because win() does the print()
-- ...as i can see

结束

And also try in win() print(res[i]) the foregoing print(3) should be print(classMates[j])