Is there something like an `addOrRemove(element, b...
# getting-started
m
Is there something like an
addOrRemove(element, boolean)
function for sets (or collections) in the stdlib? Something that does
if (boolean) set.add(element) else set.remove(element)
🚫 1
j
Not to my knowledge, but you can create your own extension for this
👍 1
m
Copy code
fun <T> MutableSet<T>.toggle(t: T) = add(t) || remove(t)