ctietze, Based on a condition, I want to make sure an element is either part of a set or removed from it.
(Like a toggle, but conditional on a Bool expression, not on the previous value.)
How would you call this?
extension Set { mutating func foo( _ element: Element, insertWhen condition: Bool ) { if condition { insert(element) } else { remove(element) } } }
Add comment