appendall

function appendall( arr, oth ) --> arr

Description

Appends all values of oth to arr.

Parameters

arr

Array table where the values should be append.

oth

Array table with the values that should be append.

Return Values

arr

Returns the modified table arr.

Code

--ZFUNC-appendall-v1
local function appendall( arr, oth ) --> arr
   for _, v in ipairs( oth ) do
      table.insert( arr, v )
   end
   return arr
end

return appendall

Examples

local t = require( "tapered" )
local appendall = require( "appendall" )

t.same( { "a", "b", "c", "d" }, appendall( { "a", "b" }, { "c", "d" } ) )

arr = { 1, 2, 3 }
appendall( arr, { 4, 5 } )
t.same( { 1, 2, 3, 4, 5 }, arr )

t.done()

Inspired by

See also