Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Forked from ezura/CodePiece.swift
Last active March 31, 2016 11:11
Show Gist options
  • Save es-kumagai/848bd97ca6f205784f3ecfc8667ba902 to your computer and use it in GitHub Desktop.
Save es-kumagai/848bd97ca6f205784f3ecfc8667ba902 to your computer and use it in GitHub Desktop.
あらら、変な guard の使い方してた(´・ω・`) #CodePiece
AnyGenerator {
defer {
iteration += 1
}
// こっちはダメ
guard iteration > 3 else {
return iteration
}
return nil
}
AnyGenerator {
defer {
iteration += 1
}
// こっちが良い
guard iteration <= 3 else {
return nil
}
return iteration
}
@es-kumagai
Copy link
Author

条件式の矛盾を修正しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment