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

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

Issue 838463002: Change List/Set/Map/Queue.from constructrs to accept any iterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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/core/set.dart
diff --git a/sdk/lib/core/set.dart b/sdk/lib/core/set.dart
index 2440c69f88bf488462a7c7d69c69c090c9bd417a..b3d73d6865e840d87e330a7fa9b7e2bd95f3e3e0 100644
--- a/sdk/lib/core/set.dart
+++ b/sdk/lib/core/set.dart
@@ -55,15 +55,24 @@ abstract class Set<E> extends IterableBase<E> implements EfficientLength {
factory Set.identity() = LinkedHashSet<E>.identity;
/**
- * Creates a [Set] that contains all elements of [other].
+ * Creates a [Set] that contains all of [elements].
+ *
+ * All the [elements] should be assignable to [E].
+ * The `elements` iterable itself can have any type,
+ * so this constructor can be used to down-cast a `Set`, for example as:
+ *
+ * Set<SuperType> superSet = ...;
+ * Set<SubType> subSet =
+ * new Set<SubType>.from(superSet.where((e) => e is SubType));
*
* The created [Set] is a [LinkedHashSet]. As such, it considers elements that
- * are equal (using [==]) to be undistinguishable, and requires them to
+ * are equal (using [==]) to be indistinguishable, and requires them to
* have a compatible [Object.hashCode] implementation.
*
- * The set is equivalent to one created by `new LinkedHashSet<E>.from(other)`.
+ * The set is equivalent to one created by
+ * `new LinkedHashSet<E>.from(elements)`.
*/
- factory Set.from(Iterable<E> other) = LinkedHashSet<E>.from;
+ factory Set.from(Iterable elements) = LinkedHashSet<E>.from;
/**
* Provides an iterator that iterates over the elements of this set.

Powered by Google App Engine
This is Rietveld 408576698