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

Remove error throwing in _.reduce & _.reduceRight. #1858

Closed
jdalton opened this issue Sep 19, 2014 · 4 comments · Fixed by #1961
Closed

Remove error throwing in _.reduce & _.reduceRight. #1858

jdalton opened this issue Sep 19, 2014 · 4 comments · Fixed by #1961

Comments

@jdalton
Copy link
Contributor

jdalton commented Sep 19, 2014

With the use of ES5 array built-ins removed from Underscore there's no longer a need to throw an error when a collection is empty and no initial value is provided in _.reduce and _.reduceRight. Thoughts?

// currently
_.reduce([], _.identity, 'a'); // => 'a'
_.reduce([], _.identity); // => throws error

// instead it could simply do:
_.reduce([], _.identity); // => undefined

This would align with changes to _.keys which no longer throws either.

@braddunbar
Copy link
Collaborator

👍

@megawac
Copy link
Collaborator

megawac commented Sep 19, 2014

👍 for #1841

@akre54 akre54 mentioned this issue Sep 19, 2014
8 tasks
@jashkenas
Copy link
Owner

Sounds great.

@yy8597
Copy link

yy8597 commented Sep 19, 2014

so nice

@megawac megawac added this to the v2.0 milestone Sep 19, 2014
jridgewell added a commit to jridgewell/underscore that referenced this issue Dec 4, 2014
@jashkenas jashkenas removed this from the v2.0 milestone Dec 11, 2014
@jdalton jdalton removed this from the v2.0 milestone Dec 11, 2014
@megawac megawac mentioned this issue Jan 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants