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

Unified Diff: sdk/lib/collection/hash_map.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/collection/hash_map.dart
diff --git a/sdk/lib/collection/hash_map.dart b/sdk/lib/collection/hash_map.dart
index 720403104240f9b1f2aacb0b37dc6ae204ab3b4d..e67fa77556fc9a1d531dd39824e2ea8506922692 100644
--- a/sdk/lib/collection/hash_map.dart
+++ b/sdk/lib/collection/hash_map.dart
@@ -80,10 +80,12 @@ abstract class HashMap<K, V> implements Map<K, V> {
external factory HashMap.identity();
/**
- * Creates a [HashMap] that contains all key value pairs of [other].
+ * Creates a [HashMap] that contains all key/value pairs of [other].
*/
- factory HashMap.from(Map<K, V> other) {
- return new HashMap<K, V>()..addAll(other);
+ factory HashMap.from(Map other) {
+ HashMap<K, V> result = new HashMap<K, V>();
+ other.forEach((k, v) { result[k] = v; });
Søren Gjesse 2015/01/05 15:35:15 Add types K and V?
Lasse Reichstein Nielsen 2015/01/06 10:14:45 The forEach method has type (K',V')->void where ot
Søren Gjesse 2015/01/06 12:09:05 Of cause.
+ return result;
}
/**

Powered by Google App Engine
This is Rietveld 408576698