-
Notifications
You must be signed in to change notification settings - Fork 87
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
[question] linq_aggregate API to avoid boxing? #12
Comments
Note : the code example above crashes since if (aggregate == nil) {
aggregate = item;
} Why are you checking this condition and assigning a wrong object? @ColinEberhardt what do you think about such use case? |
NSArray* names = @[@"bill", @"bob", @"brian"];
id aggregate = [names linq_aggregate:^id(id item, id aggregate) {
return [NSString stringWithFormat:@"%@, %@", aggregate, item];
}]; Eventually, the fix will break the code in the readme and the user will have to handle |
Issue description : ColinEberhardt#12
@ColinEberhardt I've removed the mentioned check in a patch #13 Please let me know if you find a better approach for my use case. |
Are you planning to add
linq_aggregate
API for primitive types?In this example there is a lot of boxing/unboxing (NSNumber ==> NSUInteger ==> NSNumber) which is a good thing to avoid.
P.S. I know that integers can be "safely" casted to
id
. But I strongly dislike this approach. Moreover, it does not work for[NSNumber floatValue]
.The text was updated successfully, but these errors were encountered: