unwrap

function unwrap( arr [, i [, j]] ) --> ...

Description

Returns the elements from the given list. Implemented as wrapper function around unpack or table.unpack.

Parameters

arr

Source array table with the elements.

i

The index of the first element. By default is the value 1.

j

The index of the last element. By default is the value #arr.

Return Values

Elements from the given array table.

Code

--ZFUNC-unwrap-v1
local function unwrap( arr, i, j ) --> ...
   local unpack = unpack or table.unpack
   return unpack( arr, i, j )
end

return unwrap

Example

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

two, four, eight = unwrap( { 2, 4, 8 } )
t.is( two, 2 )
t.is( four, 4 )
t.is( eight, 8 )

three, four, five = unwrap( { 1, 2, 3, 4, 5, 6, 7 }, 3, 5 )
t.is( three, 3 )
t.is( four, 4 )
t.is( five, 5 )

t.done()