Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Created July 19, 2015 10:03
Show Gist options
  • Save kasperpeulen/f290fa5bd08ab9304024 to your computer and use it in GitHub Desktop.
Save kasperpeulen/f290fa5bd08ab9304024 to your computer and use it in GitHub Desktop.
Example illustrating how to remove key/value pairs from a `Map`, where the key/value pair satisfies some test. Similar as the `List.removeWhere` method.

#dart:core example

Example illustrating how to remove key/value pairs from a Map, where the key/value pair satisfies some test. Similar as the List.removeWhere method.

Main library: dart:core
Main elements: Map Map.remove
Tags:

main() {
Map map = {
0: "not null",
1: null
};
bool test(key) => map[key] == null;
map.keys.where(test).toList().forEach(map.remove);
print(map);
}
name: dart.core_Map_Map.remove
description: >
Example illustrating how to remove key/value pairs from a `Map`, where the key/value pair satisfies some test. Similar as the `List.removeWhere` method.
homepage: https://gist.github.com/f290fa5bd08ab9304024
environment:
sdk: '>=1.0.0<2.0.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment