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( "taptest" )
local appendall = require( "appendall" )
local same = require( "same" )

arr = appendall( { "a", "b" }, { "c", "d" } )
t( same( arr, { "a", "b", "c", "d" } ), true )

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

t()

Inspired by

See also