Site Notice

hello, world

Module:Util

From Project-EPB Commons
Revision as of 23:57, 10 April 2020 by 机智的小鱼君 (talk | contribs) ([InPageEdit] 没有编辑摘要)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Util/doc

-- 常用Lua工具集
local p = {}

-- 获取表长度
function p.tabelLength(tbl)
  local length = 0
  for k, v in pairs(tbl) do
    length = length + 1
  end
  return length
end

-- 返回表中含有value值的key
function p.valueInTable(tbl, value)
  local final = {}
  for k, v in pairs(tbl) do
    if v == value then
      final[k] = v
    end
  end
  return final
end

return p