@ -126,9 +126,13 @@ class Collection extends ImmutableCollection implements ICollection {
* @inheritDoc
*/
public function sliceSelf (int $offset, ?int $length = null): static {
if ($this->count() === 0) {
$this->elements = [];
}
else {
$this->_checkOffset($offset);
$this->elements = array_slice($this->elements, $offset, $length, true);
return $this;
@ -289,9 +289,12 @@ class ImmutableCollection implements IImmutableCollection {
public function slice (int $offset, ?int $length = null): static {
$output = new static();
return $output;
$currentIndex = 0;
foreach ($this->elements as $key => $value) {