collectv

function collectv( ... ) --> arr

Description

Util function to collect all values during the generic for loop for the list of expressions(...). The value is the second value inside the generic for loop.

Parameters

One or more expressions that will be passed to the generic for loop.

Return Values

arr

Array table that contains all values.

Code

--ZFUNC-collectv-v1
local function collectv( ... ) --> arr
   local arr = {}
   for k, v in ... do
      table.insert( arr, v )
   end
   return arr
end

return collectv

Examples

local t = require( "tapered" )
local collectv = require( "collectv" )
local like = require( "like" )

src = { a="x", b="y", c="z" }
values = collectv( pairs( src ) )
t.ok( like( { "x", "y", "z" }, values ) )

t.done()

See also