Hi, I would like to modify an associated value of an existing enum instance of the the following enum:
enum FilterItem: Equatable, Hashable {
case work(isSelected: Bool)
...
var filterName: String {
switch self {
case .work: return "Work"
...
}
}
var isSelected: Bool {
switch self {
case .work(let isSelected): return isSelected
...
}
}
I want to be able to switch on the FilterItem
type and then to be able to modify the isSelected
property of the instance like:
let itemToChange: FilterItem
switch item {
case .work(let isSelected):
itemToChange.isSelected = !isSelected
I know the above code doesn't compile, but I was wondering if there was a way I could modify my enum instance without creating a totally new enum instance.