src/DS/Traits/TraitSequence.php
public function slice(int $index, ?int $length = null): Sequence
    {
        $items = $length ?
            $this->items->slice($index, $length) :
            $this->items->slice($index);

        return $this->duplicate($items);
    }
public function slice(int $index, ?int $length = null): Sequence
    {
        $items = $length ?
            $this->items->slice($index, $length) :
            $this->items->slice($index);

        return $this->duplicate($items);
    }
public function slice ( int $ index , ? int $ length = null ) : Sequence { $ items = $ length ? $ this -> items -> slice ( $ index , $ length ) : $ this -> items -> slice ( $ index ) ; return $ this -> duplicate ( $ items ) ; }
Returns a sub-sequence of a given length starting at a specified index.

@param int $index  If the index is positive, the sequence will start
at that index in the sequence. If index is
negative, the sequence will start that far from
the end.

@param int $length If a length is given and is positive, the resulting
sequence will have up to that many values in it.
If the length results in an overflow, only values
up to the end of the sequence will be included.

If a length is given and is negative, the sequence
will stop that many values from the end.

If a length is not provided, the resulting sequence
will contain all values between the index and the
end of the sequence.

@return \PlanB\DS\Sequence
Returns a sub - sequence of a given length starting at a specified index .