Last active
December 19, 2015 21:28
-
-
Save alladinian/6019910 to your computer and use it in GitHub Desktop.
Just a bad idea...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSMutableArray (badidea) | |
- (NSArray *) upto:(NSUInteger)n; | |
@end | |
@implementation NSMutableArray (badidea) | |
- (NSArray *) upto:(NSUInteger)n | |
{ | |
if (n==0) return self.reverseObjectEnumerator.allObjects; | |
[self addObject:@(n)]; | |
return [self upto:(n-1)]; | |
} | |
@end | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
NSMutableArray *array = [NSMutableArray array]; | |
NSLog(@"%@", [array upto:50]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment