In Swift you can check the class type of an object using \'is\'. How can I incorporate this into a \'switch\' block?
I think it\'s not possible, so I\'m wondering w
Putting up the example for "case is - case is Int, is String:" operation, where multiple cases can be used clubbed together to perform the same activity for Similar Object types. Here "," separating the types in case is operating like a OR operator.
switch value{
case is Int, is String:
if value is Int{
print("Integer::\(value)")
}else{
print("String::\(value)")
}
default:
print("\(value)")
}
Demo Link