toggle method

IList<T> toggle(
  1. T element
)

Removes the first instance of the element, if it exists in the list. Otherwise, adds it to the list.

Implementation

IList<T> toggle(T element) => contains(element) ? remove(element) : add(element);