Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Update the docs to reflect the merge of reduceWithKeys into the existing reduce method #6743

Merged
merged 6 commits into from Jan 15, 2021

Conversation

mokhosh
Copy link
Contributor

@mokhosh mokhosh commented Jan 14, 2021

This updates Collection docs to reflect latest changes in reduce

As discussed here: laravel/framework#35839
The new pull request to framework here: laravel/framework#35878
Previous change to the docs that was merged and needs to be updated because the underlying changed was reverted here: #6740

@@ -1725,7 +1721,7 @@ The `reduceWithKeys` method reduces an associative collection to a single value,

$collection->reduceWithKeys(function ($carry, $value, $key) use ($ratio) {
return $carry + ($value * $ratio[$key]);
}, 0);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I previously added 0 as $initialValue to the example to make it clear that reduceWithKeys also accepts initial value. But now that it's merged into reduce and we already show that in the previous example there is no need for that and we can remove it to simplify and make it more readable.

@taylorotwell taylorotwell merged commit b24b6bb into laravel:8.x Jan 15, 2021
@Hornet-Wing
Copy link

I got confused by this one, should this one not be something like this?

"The reduceWithKeys method also passes array keys in associative collections to the given callback"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants