Index: sdk/lib/collection/set.dart |
diff --git a/sdk/lib/collection/set.dart b/sdk/lib/collection/set.dart |
index 906312adfed50af1f50d98ad0169f827638f010a..74707611a7bbe6ca32cb97947dbf28bfe0ccb247 100644 |
--- a/sdk/lib/collection/set.dart |
+++ b/sdk/lib/collection/set.dart |
@@ -271,13 +271,14 @@ abstract class SetMixin<E> implements Set<E> { |
} |
E elementAt(int index) { |
- if (index is! int || index < 0) throw new RangeError.value(index); |
- int remaining = index; |
+ if (index is! int) throw new ArgumentError.notNull("index"); |
+ RangeError.checkNotNegative(index, "index"); |
+ int elementIndex = 0; |
for (E element in this) { |
- if (remaining == 0) return element; |
- remaining--; |
+ if (index == elementIndex) return element; |
+ elementIndex++; |
} |
- throw new RangeError.value(index); |
+ throw new RangeError.index(index, this, "index", null, elementIndex); |
} |
} |