Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: sdk/lib/collection/list.dart

Issue 331833003: Revert "Add "last" setter to List." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/lib/js_array.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/list.dart
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index 6b1ad17ff2e61bc46932c00a1883a00870abdc04..b6e1a11b66e2882ebfc6701a9ecaf54787d7a460 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -70,23 +70,18 @@ abstract class ListMixin<E> implements List<E> {
bool get isNotEmpty => !isEmpty;
E get first {
- if (length == 0) throw IterableElementError.noElement();
+ if (length == 0) throw new StateError("No elements");
return this[0];
}
E get last {
- if (length == 0) throw IterableElementError.noElement();
+ if (length == 0) throw new StateError("No elements");
return this[length - 1];
}
- void set last(E value) {
- if (length == 0) throw IterableElementError.noElement();
- this[length - 1] = value;
- }
-
E get single {
- if (length == 0) throw IterableElementError.noElement();
- if (length > 1) throw IterableElementError.tooMany();
+ if (length == 0) throw new StateError("No elements");
+ if (length > 1) throw new StateError("Too many elements");
return this[0];
}
@@ -133,7 +128,7 @@ abstract class ListMixin<E> implements List<E> {
}
}
if (orElse != null) return orElse();
- throw IterableElementError.noElement();
+ throw new StateError("No matching element");
}
dynamic lastWhere(bool test(E element), { Object orElse() }) {
@@ -146,7 +141,7 @@ abstract class ListMixin<E> implements List<E> {
}
}
if (orElse != null) return orElse();
- throw IterableElementError.noElement();
+ throw new StateError("No matching element");
}
E singleWhere(bool test(E element)) {
@@ -157,7 +152,7 @@ abstract class ListMixin<E> implements List<E> {
E element = this[i];
if (test(element)) {
if (matchFound) {
- throw IterableElementError.tooMany();
+ throw new StateError("More than one matching element");
}
matchFound = true;
match = element;
@@ -167,7 +162,7 @@ abstract class ListMixin<E> implements List<E> {
}
}
if (matchFound) return match;
- throw IterableElementError.noElement();
+ throw new StateError("No matching element");
}
String join([String separator = ""]) {
@@ -184,7 +179,7 @@ abstract class ListMixin<E> implements List<E> {
new ExpandIterable<E, dynamic>(this, f);
E reduce(E combine(E previousValue, E element)) {
- if (length == 0) throw IterableElementError.noElement();
+ if (length == 0) throw new StateError("No elements");
E value = this[0];
for (int i = 1; i < length; i++) {
value = combine(value, this[i]);
@@ -293,7 +288,7 @@ abstract class ListMixin<E> implements List<E> {
E removeLast() {
if (length == 0) {
- throw IterableElementError.noElement();
+ throw new StateError("No elements");
}
E result = this[length - 1];
length--;
@@ -381,7 +376,7 @@ abstract class ListMixin<E> implements List<E> {
otherStart = 0;
}
if (otherStart + length > otherList.length) {
- throw IterableElementError.noElement();
+ throw new StateError("Not enough elements");
}
if (otherStart < start) {
// Copy backwards to ensure correct copy if [from] is this.
« no previous file with comments | « sdk/lib/_internal/lib/js_array.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698