You need the is
pattern:
func doSomething<T>(type: T.Type) {
switch type {
case is String.Type:
print("It's a String")
case is Int.Type:
print("It's an Int")
default:
print("Wot?")
}
}
Note that the break
statements are usually not needed, there is no
“default fallthrough” in Swift cases.