Skip to content

Commit

Permalink
Update Reduction operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 29, 2019
1 parent 96decd5 commit 8964acc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/drupol/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ static function ($carry, $item) {
},
0
)
->shouldIterateAs([0, 1, 3, 6, 10, 15]);
->shouldIterateAs([1, 3, 6, 10, 15]);
}

public function it_can_reverse(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Reduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function on(iterable $collection): Closure
$initial = $this->initial;

return static function () use ($callback, $initial, $collection): Generator {
yield $carry = $initial;
$carry = $initial;

foreach ($collection as $key => $value) {
yield $carry = $callback($carry, $value, $key);
Expand Down

0 comments on commit 8964acc

Please sign in to comment.