【AndroLua+】一个野生的判断表中是否存在某一项的例子

avatar

azurekiln

-- 检查表中是否含有某一项
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")

扫描二维码,在手机上阅读
收藏
请先 登录 再评论
powered by emlog pro
服务器供应商 新区云数据

友情链接
白衣Ink


sitemap