endsWith method

bool endsWith(
  1. Iterable<T> other, {
  2. bool comparer(
    1. T value,
    2. T otherValue
    )?,
})

Returns true if this iterable ends with the same elements that are in other.

Implementation

bool endsWith(
  Iterable<T> other, {
  bool Function(T value, T otherValue)? comparer,
}) {
  comparer ??= EqualityComparer.forType<T>().compare;

  final count = other.count();
  final tail = takeLast(count);

  return tail.sequenceEquals(other, comparer: comparer);
}