Add example for gears.table.count_keys

Signed-off-by: Lucas Schwiderski <lucas@lschwiderski.de>
This commit is contained in:
Lucas Schwiderski 2021-03-22 20:55:40 +01:00
parent 058190a3c0
commit afced71a9a
No known key found for this signature in database
GPG Key ID: AA12679AAA6DF4D8
2 changed files with 8 additions and 0 deletions

View File

@ -169,6 +169,8 @@ end
--
-- This is functionally equivalent, but faster than `#gears.table.keys(t)`.
--
-- @DOC_text_gears_table_count_keys_EXAMPLE@
--
-- @tparam table t The table for which to count the keys.
-- @treturn number The number of keys in the table.
-- @staticfct gears.table.count_keys

View File

@ -0,0 +1,6 @@
--DOC_GEN_OUTPUT --DOC_HIDE
local gears = require("gears") --DOC_HIDE
local tab = { 1, nil, "a", "b", foo = "bar" }
local count = gears.table.count_keys(tab)
print("The table has " .. count .. " keys")