Skip to content

Instantly share code, notes, and snippets.

@hborders hborders/MissingReturn.m
Last active May 14, 2018

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.