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

Unified Diff: sdk/lib/_collection_dev/iterable.dart

Issue 18837002: Move toString() to collection classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
Index: sdk/lib/_collection_dev/iterable.dart
diff --git a/sdk/lib/_collection_dev/iterable.dart b/sdk/lib/_collection_dev/iterable.dart
index 6e1e5ecb7c1b79be349de5fd215359d8294a6b0e..2f7746f85def3dd70607e1197333df0541d70892 100644
--- a/sdk/lib/_collection_dev/iterable.dart
+++ b/sdk/lib/_collection_dev/iterable.dart
@@ -895,6 +895,38 @@ class IterableMixinWorkaround {
return buffer.toString();
}
+ static String toStringIterable(Iterable iterable) {
+ var result = new StringBuffer();
floitsch 2013/07/08 12:00:50 Move checking of recursive iterables in here.
zarah 2013/07/08 14:35:15 Done.
+
+ result.write('{');
+ bool first = true;
+ for (var e in iterable) {
+ if (!first) {
+ result.write(', ');
+ }
+ first = false;
+ result.write(e);
+ }
+ result.write('}');
+
+ return result.toString();
+ }
+
+ static String toStringList(List list) {
floitsch 2013/07/08 12:00:50 Move checking of recursive lists in here.
zarah 2013/07/08 14:35:15 Done.
+ var result = new StringBuffer();
+ result.write('[');
+ for (int i = 0; i < list.length; i++) {
+ if (i > 0) {
+ result.write(', ');
+ }
+ result.write(list[i]);
+ }
+ result.write(']');
+
+ return result.toString();
+ }
+
+
static Iterable where(Iterable iterable, bool f(var element)) {
return new WhereIterable(iterable, f);
}
@@ -982,6 +1014,7 @@ class IterableMixinWorkaround {
otherList = from.skip(skipCount).toList(growable: false);
otherStart = 0;
}
+
if (otherStart + length > otherList.length) {
throw new StateError("Not enough elements");
}

Powered by Google App Engine
This is Rietveld 408576698