Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

-[NSArray reduce:withBlock:] implementation is incorrect #119

Open
soxjke opened this issue Mar 30, 2017 · 0 comments
Open

-[NSArray reduce:withBlock:] implementation is incorrect #119

soxjke opened this issue Mar 30, 2017 · 0 comments

Comments

@soxjke
Copy link

soxjke commented Mar 30, 2017

When initial value is set to nil and the array consists of single item, this item is returned and reduce block is never evaluated.

There seems to be an issue at https://github.com/supermarin/ObjectiveSugar/blob/master/Classes/NSArray%2BObjectiveSugar.m#L178

I would rather write it as

accumulator = block(accumulator, object);

Does this make sense?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant