Skip to content

Instantly share code, notes, and snippets.

@SteeweGriffin
Created February 22, 2018 12:13
Show Gist options
  • Save SteeweGriffin/061373a99fca2f4727f65fdbb26f458f to your computer and use it in GitHub Desktop.
Save SteeweGriffin/061373a99fca2f4727f65fdbb26f458f to your computer and use it in GitHub Desktop.
enum EnumType:Any {
case none
case firstType(value:String)
case secondTypeA(value1:String, value2:Int)
case secondTypeB(value1:String, value2:Int)
}
func checkEnumType(type:EnumType) {
switch type {
case .none:
print("none")
case let .firstType(value):
print(value)
case let .secondTypeA(value1, value2):
print(value1)
print(value2)
case let .secondTypeB(value1, value2):
print(value1)
print(value2)
}
}
checkEnumType(type: .none)
checkEnumType(type: .firstType(value: "pippo"))
checkEnumType(type: .secondTypeA(value1: "baudo", value2: 2))
checkEnumType(type: .secondTypeB(value1: "capellone", value2: 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment