Created
May 5, 2016 10:00
-
-
Save tikidunpon/f64cb151796e241a1a0a93aae551a43a to your computer and use it in GitHub Desktop.
こんな気持ち悪い解決策になってしまった.. #swift2 #CodePiece #swift #swiftlang
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
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) } |
これだとswitchでDummyも書かないといけないから結局ダメな感じ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ここを参考にしました。 http://stdsk.hatenablog.com/entry/2015/08/05/183432