minusElement method

KtList<T> minusElement(
  1. T element
)

Returns a list containing all elements of the original collection without the first occurrence of the given element.

Implementation

KtList<T> minusElement(T element) {
  final result = mutableListOf<T>();
  var removed = false;
  filterTo(result, (it) {
    if (!removed && it == element) {
      removed = true;
      return false;
    } else {
      return true;
    }
  });
  return result;
}