Skip to content

Commit

Permalink
doc: fix duplicate example (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
rela589n committed Nov 12, 2023
1 parent 0ca96c8 commit 904df55
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/pages/code/operations/duplicate.php
Expand Up @@ -32,7 +32,7 @@ public function name(): string
];

$collection = Collection::fromIterable($users)
->distinct(
->duplicate(
static fn (User $left): Closure => static fn (User $right): bool => $left->name() === $right->name()
); // [2 => User<foo>]

Expand All @@ -47,15 +47,15 @@ public function name(): string
}
}

$users = [
$people = [
new Person('foo'),
new Person('bar'),
new Person('foo'),
new Person('a'),
];

$collection = Collection::fromIterable($users)
->distinct(
$collection = Collection::fromIterable($people)
->duplicate(
null,
static fn (Person $person): string => $person->name()
); // [2 => Person<foo>]
Expand All @@ -71,15 +71,15 @@ public function name(): string
}
}

$users = [
$cats = [
new Cat('izumi'),
new Cat('nakano'),
new Cat('booba'),
new Cat('booba'),
];

$collection = Collection::fromIterable($users)
->distinct(
$collection = Collection::fromIterable($cats)
->duplicate(
static fn (string $left): Closure => static fn (string $right): bool => $left === $right,
static fn (Cat $cat): string => $cat->name()
); // [3 => Cat<booba>]

0 comments on commit 904df55

Please sign in to comment.