This is what I mean.
enum Device {
case iPhone_13Pro, iPhone_12Pro
case iPadPro_129
case iPadPro_11
}
// Hypothetical Scenario
enum Device_Group {
case iPhones
case iPads
}
Is there any way to do as above to represent a certain group of cases like this (it can be another enum OR a different case within the same enum - so that I could do as below?
// DO THIS
switch device {
case iPhones:
print("These are iPhones")
case iPads:
print("These are iPads")
}
// INSTEAD OF THIS
switch device {
case .iPhone_13Pro, .iPhone_12Pro:
print("These are iPhones")
case .iPadPro_129, .iPadPro_11:
print("These are iPads")
}
I dont know if this might be a weird question, but I find that grouping multiple cases has a certain benefit while using a switch statement. Would appreciate any advise on this. Thanks in advance.