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( "tapered" )
local values = require( "values" )
-- util functions
local like = require( "like" )

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

t.done()

See also