Skip to content

Commit

Permalink
The $fn callback of the map function adds the key parameter passed in…
Browse files Browse the repository at this point in the history
…to the $list array (#160)

Co-authored-by: echo <[email protected]>
  • Loading branch information
maxiaozhi and echo authored Dec 9, 2023
1 parent 1de2307 commit 4e3efcc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/Coroutine/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function map(array $list, callable $fn, float $timeout = -1): array
foreach ($list as $id => $elem) {
Coroutine::create(function () use ($wg, &$list, $id, $elem, $fn): void {
$list[$id] = null;
$list[$id] = $fn($elem);
$list[$id] = $fn($elem, $id);
$wg->done();
});
}
Expand Down

0 comments on commit 4e3efcc

Please sign in to comment.