Closed johnno1962 closed 10 years ago
The following test will fail when two adjacent values do not meet the condition as it will skip an element:
NSMutableArray *ma = [NSMutableArray arrayWithObjects:@1, @3, @10, nil]; [ma keepIf:^BOOL(id object) { return [object intValue] > 5; }]; if ( ![ma isEqual:@[@10]] ) XCTFail(@"fail …
The alternative is to go through the array in reverse order though in a way this is less intuitive.
@johnno1962 thanks for the contribution. Would you mind writing a test for this?
Test written though it is a separate pull request as I deleted the original fork
The following test will fail when two adjacent values do not meet the condition as it will skip an element:
The alternative is to go through the array in reverse order though in a way this is less intuitive.