public function merge(self $list) : self
    {
        $oldSize = $this->getSize();
        $combinedSize = $oldSize + $list->getSize();
        $old = $this->list;
        $old->setSize($combinedSize);

        foreach ($old as $index => $val) {
            if ($index > $oldSize - 1) {
                $old[$index] = $list->getList()[($index - $oldSize)];
            }
        }

        return new static($old);
    }
public function merge(self $list) : self
    {
        $oldSize = $this->getSize();
        $combinedSize = $oldSize + $list->getSize();
        $old = $this->list;
        $old->setSize($combinedSize);

        foreach ($old as $index => $val) {
            if ($index > $oldSize - 1) {
                $old[$index] = $list->getList()[($index - $oldSize)];
            }
        }

        return new static($old);
    }
public function merge ( self $ list ) : self { $ oldSize = $ this -> getSize ( ) ; $ combinedSize = $ oldSize + $ list -> getSize ( ) ; $ old = $ this -> list ; $ old -> setSize ( $ combinedSize ) ; foreach ( $ old as $ index => $ val ) { if ( $ index > $ oldSize - 1 ) { $ old [ $ index ] = $ list -> getList ( ) [ ( $ index - $ oldSize ) ] ; } } return new static ( $ old ) ; }
merge method.

@method merge

@param Collection $list

@return object Collection
merge method .