ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 3db0213e7e386a0a4c7f603b27b943f85355da68
parent 3d831cc1199d1eee2ec640dd1b5d5e4dd13dd2e0
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Fri, 19 Jan 2018 19:37:34 -0500

Add a table length function.

Diffstat:
Mfunctions/table-utils.lua | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/functions/table-utils.lua b/functions/table-utils.lua @@ -57,4 +57,15 @@ function tableutils.haskey(tab, key) return false end +-- length +function tableutils.length(tab) + local count = 0 + + for _ in pairs(tab) do + count = count + 1 + end + + return count +end + return tableutils