-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add whereKey, whereValue, whereKeyValue on Iterable<MapEntry> #22
Comments
Come to think of it, |
This an interesting idea, personally I feel like it might make more sense as an extension of Would something like this be similarly useful? void main() {
print({1: 2, 3: 5, 6: 7}.whereKey((key) => key % 2 == 0));
// Returns {6: 7}
}
extension Foo on Map {
Map whereKey<K, V>(bool Function(K) callback) {
return Map.fromEntries(this.entries.where((entry) => callback(entry.key)));
}
}
|
Yes, that would also solve what I'm trying to do. 👌 It's not quite as efficient though, because it would convert the |
Dealing with
MapEntry
s is cumbersome:Extension methods for
whereKey
,whereValue
andwhereKeyValue
onIterable<MapEntry<K, V>>
could make this much more readable:The text was updated successfully, but these errors were encountered: