isfilled

function isfilled( tab ) --> res

Description

Returns true if a table contains values.

Parameters

tab

Table that should be checked.

Return Values

res

true if the table contains values, otherwise false.

Code

--ZFUNC-isfilled-v1
local function isfilled( tab ) --> res
   for _, v in pairs( tab ) do return true end
   return false
end

return isfilled

Examples

local t = require( "taptest" )
local isfilled = require( "isfilled" )

t( isfilled{}, false )
t( isfilled{ 1, 2, 3 }, true )

tab = { single_value="1" }
t( isfilled( tab ), true )
tab.single_value = nil
t( isfilled( tab ), false )

t()

See also