Here is a common enum with associated values.
enum MultiplierType {
case width(Double)
case height(Double)
case xxxxx1(Double)
case xxxxx2(Double)
case xxxxx3(Double)
var value: Double {
switch self {
// Normal way.
case let .width(value):
return value
case let .height(value):
return value
case let .xxxxx1(value):
return value
...
}
}
}
My question is how to do like this?
var value: Double {
switch self {
// How to get the value in one case?
case let .width(value), .height(value), .xxx:
return value
}
}
Or
var value: Double {
switch self {
// How to get the value in one case?
case let .width, .height, .xxx (value):
return value
}
}
What is the most elegant way to get the associated value?