Last active
February 27, 2017 05:40
-
-
Save bkobilansky/402ea6dab7fe782a5e5caab3e564347c to your computer and use it in GitHub Desktop.
Objective-C blocks empty param list is not void
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> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
// note that an empty list here doesn't mean "no params" | |
void (^printNSArray)(); | |
printNSArray = ^(NSArray *items) { | |
// deliberately safe to prove a point | |
NSLog(@"%@", items); | |
}; | |
// an empty list means we actually pass whatever we'd like | |
printNSArray(@[@"foo", @"bar", @"baz"]); | |
printNSArray(@"quux"); | |
printNSArray([[NSObject alloc] init]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment