# elementAt method

1. @override

E elementAt(

1. int index

)
override

Returns the `index`th element.

The `index` must be non-negative and less than length. Index zero represents the first element (so `iterable.elementAt(0)` is equivalent to `iterable.first`).

May iterate through the elements in iteration order, ignoring the first `index` elements and then returning the next. Some iterables may have a more efficient way to find the element.

Example:

    final numbers = <int>[1, 2, 3, 5, 6, 7];
    final elementAt = numbers.elementAt(4); // 6

## Implementation

    @override
    E elementAt(int index) {
      if (index < 0 || index >= _size) {
        throw RangeError.index(index, this, 'index', null, _size);
      }
      int count = 0;
      for (final element in this) {
        if (count == index) {
          return element;
        }
        count++;
      }
      // Should not be reached if index is valid
      throw IllegalStateException('Element not found at index $index');
    }