Skip to content

Instantly share code, notes, and snippets.

@hborders
Last active May 14, 2018 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hborders/4f7751f7c2b4029054a1e16fc88b7593 to your computer and use it in GitHub Desktop.
Save hborders/4f7751f7c2b4029054a1e16fc88b7593 to your computer and use it in GitHub Desktop.
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