containsAny method

bool containsAny(
  1. List<T> elements
)

Determines if the calling list contains any elements from the provided list.

@param elements A list of elements to check against the calling list. @return bool Returns true if the calling list contains at least one element from the elements list, false otherwise.

@example final myList = 1, 2, 3, 4, 5; bool result = myList.containsAny(0, 5); // true

Implementation

bool containsAny(List<T> elements) {
  for (T element in elements) {
    if (this.contains(element)) {
      return true;
    }
  }

  return false;
}