GetEnumeratedObjectAt static method

Object GetEnumeratedObjectAt(
  1. Iterable objects,
  2. int index
)
Gets enumerated object at index. The objects. The index.

Implementation

static Object GetEnumeratedObjectAt(Iterable objects, int index) {
  int count = 0;

  for (Object obj in objects as Iterable<Object>) {
    if (count == index) {
      return obj;
    }

    count++;
  }

  throw RangeError.range(
    index,
    0,
    count,
    "index",
    "Strings.IterableDoesNotContainThatManyObject",
  );
}