Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.