Index: sdk/lib/collection/collections.dart |
diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart |
index f51d98daaabeb87b5ab5bb1613a0f12e4fd5cc6e..95d5a43dedf80fdd0e63f73b14b3e08c63a2b94f 100644 |
--- a/sdk/lib/collection/collections.dart |
+++ b/sdk/lib/collection/collections.dart |
@@ -39,9 +39,14 @@ class IterableMixinWorkaround { |
} |
static dynamic reduce(Iterable iterable, |
- dynamic initialValue, |
- dynamic combine(dynamic previousValue, element)) { |
- return fold(iterable, initialValue, combine); |
+ dynamic combine(previousValue, element)) { |
+ Iterator iterator = iterable.iterator; |
+ if (!iterator.moveNext()) throw new StateError("No elements"); |
+ var value = iterator.current; |
+ while (iterator.moveNext()) { |
+ value = combine(value, iterator.current); |
+ } |
+ return value; |
} |
static dynamic fold(Iterable iterable, |