Skip to content

Instantly share code, notes, and snippets.

@tralamazza
Created February 20, 2012 19:06
Show Gist options
  • Select an option

  • Save tralamazza/1870771 to your computer and use it in GitHub Desktop.

Select an option

Save tralamazza/1870771 to your computer and use it in GitHub Desktop.
NSMutableArray* yay = [NSMutableArray new];
[yay addObject:@"1"];
[yay addObject:@"2"];
[yay addObject:@"3"];
NSNumber* reduced = [yay reduce:[NSNumber numberWithInt:0] block:^id(id sum, id i) {
return [NSNumber numberWithInt:[sum intValue] + [i intValue]];
}];
STAssertEquals([reduced intValue], 6, @"whut?!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment