下記のswitch文をご覧ください。私はテストを実行するためのより賢い方法を探しています。次のようなもの:enumの値と関連する列挙型の値を1つのcase文で確認するにはどうすればよいですか?
case let .b(other) where .x = other // This does not compile
可能でしょうか?
enum MyEnum {
case a
case b(MyOtherEnum)
}
enum MyOtherEnum {
case x
case y
}
func check(value: MyEnum) {
switch value {
case let .b(other):
if case .x = other {
print("Got it!")
}
default:
break
}
}
ありがとう、ありがとう – Verticon