Table.empty
Jump to navigation
Jump to search
This function check is empty table or not.
Syntax
boolean table.empty( table a )
Required Arguments
- a: The table to check is empty table or not.
Returns
Returns the true if table is empty or false in otherwise.
Click to collapse [-]
Codefunction table.empty( a ) if type( a ) ~= "table" then return false end return not next( a ) end
Click to collapse [-]
Exampleprint( 'empty = ' .. tostring( table.empty { [0] = 1 } ) ) -- false print( 'empty = ' .. tostring( table.empty { [10] = 10, [2] = 2 } ) ) -- false print( 'empty = ' .. tostring( table.empty { } ) ) -- true