Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Apr 11, 2023
1 parent 4f57bed commit 6dbd089
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ private static function joinYield(iterable $left, iterable $right): iterable
*/
public function unpack(?callable $func = null): self
{
$func = $func ?? static function (...$args) {
yield from $args;
};
if (null === $func) {
return $this->flatten();
}

return $this->map(static function (iterable $args = []) use ($func) {
/** @psalm-suppress InvalidArgument */
Expand All @@ -219,7 +219,9 @@ public function unpack(?callable $func = null): self
*/
public function flatten(): self
{
return $this->unpack();
return $this->map(static function (iterable $args = []) {
yield from $args;
});
}

/**
Expand Down

0 comments on commit 6dbd089

Please sign in to comment.