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( "tapered" )
local isfilled = require( "isfilled" )

t.nok( isfilled{} )
t.ok( isfilled{ 1, 2, 3 } )

tab = { single_value="1" }
t.ok( isfilled( tab ) )
tab.single_value = nil
t.nok( isfilled( tab ) )

t.done()

See also