Skip to content

Instantly share code, notes, and snippets.

@tikidunpon
Created May 5, 2016 10:00
Show Gist options
  • Save tikidunpon/f64cb151796e241a1a0a93aae551a43a to your computer and use it in GitHub Desktop.
Save tikidunpon/f64cb151796e241a1a0a93aae551a43a to your computer and use it in GitHub Desktop.
こんな気持ち悪い解決策になってしまった.. #swift2 #CodePiece #swift #swiftlang
enum Color : Int {
case Red, Green, Blue
case Dummy
}
extension Color: ForwardIndexType {
func successor() -> Color {
return Color(rawValue: self.rawValue + 1) ?? Color.Dummy
}
}
(Color.Red ... .Blue).map{ print($0) }
@tikidunpon
Copy link
Author

これだとswitchでDummyも書かないといけないから結局ダメな感じ

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