Skip to content
This repository has been archived by the owner on Jun 20, 2018. It is now read-only.

Commit

Permalink
Fixes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
italolelis committed Dec 1, 2015
1 parent 824d82f commit 0e29547
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Traits/CommonMutableContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Collections\ArrayList;
use Collections\Dictionary;
use Collections\Iterable;
use Collections\VectorInterface;

trait CommonMutableContainerTrait
{
Expand Down Expand Up @@ -78,7 +79,8 @@ public function groupBy($callback)
foreach ($this as $value) {
$key = $callback($value);
if (!$group->containsKey($key)) {
$group->add($key, new static([$value]));
$element = $this instanceof VectorInterface ? new static([$value]) : new ArrayList([$value]);
$group->add($key, $element);
} else {
$value = $group->get($key)->add($value);
$group->set($key, $value);
Expand Down

0 comments on commit 0e29547

Please sign in to comment.