如果我在枚举中设置了我的案例,我可以在switch语句中调用多个这些案例吗?即类似于case .a, .b: return true
enum myLetters {
case a
case b
case c
var myCondition: Bool {
switch self {
case .a, .b: return true
case .c: return false
default: return false
}
}
}
default
情况是多余的)- 你具体有什么问题? - Hamishswitch
语句涵盖了这三个值,使用default
是没有意义的。它永远不会被执行到。 - rmaddy