Created
February 8, 2019 09:38
-
-
Save simme/0cd732a41e00b1962e6a40934fb2f702 to your computer and use it in GitHub Desktop.
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 MySpecialEnum { | |
case someCase | |
case someCaseWithAssociatedData(String) | |
case someCaseWithNumbers(Int) | |
} | |
func handleSpecialEnum(_ value: MySpecialEnum) { | |
switch value { | |
case .someCase: | |
justDoSomething() | |
case let .someCaseWithAssociatedData(stringValue) where stringValue == "foo": | |
handleFoo() | |
case let .someCaseWithAssociatedData(stringValue): | |
handleAssociatedData(stringValue) | |
case let .someCaseWithNumbers(integerValue) where integerValue < 10: | |
handleSmallNumbers(integerValue) | |
case let .someCaseWithNumbers(integerValue): | |
handleBigNumbers(integerValue) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment