Last active
May 14, 2018 20:11
-
-
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
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 "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