values

function values( tab ) --> arr

Description

Return an array table containing all the values in the table.

Parameters

tab

The table from where you want to read the values.

Return Values

arr

An array table with the values.

Code

--ZFUNC-values-v1
local function values( tab ) --> arr
   local arr = {}

   for k, v in pairs( tab ) do
      table.insert( arr, v )
   end

   return arr
end

return values

Examples

local t = require( "taptest" )
local like = require( "like" )
local values = require( "values" )

res = values{ even=2, odd=3, name="pierrot" }
t( like( res, { 2, 3, "pierrot" } ), true )

t()

See also