toggle method
Removes the first instance of the element, if it exists in the list. Otherwise, adds it to the list.
Implementation
@useResult
IList<T> toggle(T element) => contains(element) ? remove(element) : add(element);
Removes the first instance of the element, if it exists in the list. Otherwise, adds it to the list.
@useResult
IList<T> toggle(T element) => contains(element) ? remove(element) : add(element);