Created
March 31, 2016 10:52
-
-
Save ezura/f443a90ae61cd697f7f9b76be96a1079 to your computer and use it in GitHub Desktop.
あらら、変な guard の使い方してた(´・ω・`) #CodePiece
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
AnyGenerator { | |
defer { | |
iteration += 1 | |
} | |
// こっちはダメ | |
guard iteration > 3 else { | |
return iteration | |
} | |
return nil | |
} | |
AnyGenerator { | |
defer { | |
iteration += 1 | |
} | |
// こっちが良い | |
guard iteration < 3 else { | |
return nil | |
} | |
return iteration | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment