【AndroLua+】一个野生的判断表中是否存在某一项的例子
-- 检查表中是否含有某一项
function check_exists(tables, key)
for index, content in pairs(tables) do
if content:find(key) then
return true
end
end
end
my_table = { "apple", "banana", "fruit"}
-- 判断表 my_table 中是否存在 apple
is_exists = check_exists(my_table, "apple")
扫描二维码,在手机上阅读
收藏