-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Map ctor: Map.convert (or optional args to .from) #11751
Comments
Added Area-Library, Triaged labels. |
We could make keySelector and valueSelector optional arguments on Map.from. Removed Type-Defect label. |
That's good, too. |
Why not just use new Map.fromIterables(map.keys.map(keySelector), map.values.map(valueSelector)) or |
Bumping this again. .fromIterables requires 2 iterations through the source map. Depending on the implementation, this could be pretty expensive. |
A |
Also see #9590 which asks for the same thing as instance-method. |
I think there are nicer solutions:
|
I'm super happy with fromEntries now... |
See https://code.google.com/p/dart/issues/detail?id=11750
Map.convert(Map other, {K keySelector(key, value), V valueSelector(key, value)})
The default keySelector selects the keys. The default valueSelector selects the values.
So the default behavior is the same as Map.from(map)
I might like this more than the suggestion in 11750, if it was adopted by the other Map subclasses. Then one gets the flexibility of choosing which subclass to use with the same functionality.
The text was updated successfully, but these errors were encountered: