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

Added 'key' parameter into callable for 'reduce' and 'reductions' functions #28

Closed
wants to merge 2 commits into from

Conversation

alxsad
Copy link

@alxsad alxsad commented Aug 24, 2015

iter\reduce(function ($acc, $value, $key) {
    $acc .= sprintf("%s: %s\n", $key, $value);
    return $acc;
}, $response->headers->all(), '');

Alex Davidovich and others added 2 commits August 24, 2015 13:26
@nikic
Copy link
Owner

nikic commented Aug 25, 2015

Merged via 5527ca4, thanks! Note that this is a BC breaking change, because internal functions do not allow additional arguments.

Maybe we should also extend this (providing a $key) to other functions in the library. Functions where this would seem reasonable are map, filter, apply, any, all, search, takeWhile, dropWhile. One weird case is mapKeys/reindex -- this is the same function, with one accepting only key and the other only value.

@nikic nikic closed this Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants