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

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

Issue 1152483002: Add Iterable.empty constructor. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | sdk/lib/internal/iterable.dart » ('j') | tests/corelib/iterable_empty_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/iterable.dart
diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart
index e435b1e7680786539216842297b416d9cc6541e1..616009d2b79b9c7cf044bede4d2410470654d3cd 100644
--- a/sdk/lib/core/iterable.dart
+++ b/sdk/lib/core/iterable.dart
@@ -102,6 +102,17 @@ abstract class Iterable<E> {
}
/**
+ * Creates an empty iterable.
+ *
+ * The empty iterable has no elements, and iterating it always stops
+ * immediately.
+ *
+ * An empty iterable can be used in places where you always know that
+ * the iterable you would otherwise is always empty.
Søren Gjesse 2015/05/21 09:10:06 Seems like there is a word missing after "otherwis
+ */
+ const factory Iterable.empty() = EmptyIterable<E>;
kevmoo 2015/05/21 15:07:06 Why is this useful over using `const []`?
Lasse Reichstein Nielsen 2015/05/21 15:16:51 Because const[] is a List, not just an Iterable. Y
+
+ /**
* Returns a new `Iterator` that allows iterating the elements of this
* `Iterable`.
*
« no previous file with comments | « no previous file | sdk/lib/internal/iterable.dart » ('j') | tests/corelib/iterable_empty_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698