Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of the compiler error when get when we miss a return that a block requires
#import "Example.h" // https://gist.github.com/hborders/2af9b39e27b62ef9e68c65085126fe4a
- (void)missingReturn {
Example * _Nonnull fooExample = [[ExampleFoo alloc] initWithF:@"foo"
g:@"goo"];
NSNumber * _Nonnull number =
[ExampleSwitcher<NSNumber *> nonnullExampleFrom:fooExample
switchFoo:^(ExampleFoo * _Nonnull foo_) {
return @(foo_.f.length + foo_.g.length);
}
bar:^(ExampleBar * _Nonnull bar_) {
// should be:
// return @(bar_.b.length + bar.c.length);
@(bar_.b.length + bar.c.length);
}];
//^
// error: control reaches end of non-void block
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment