Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Created August 5, 2015 03:52
Show Gist options
  • Select an option

  • Save kasperpeulen/b6c43224f958f7ae9e4f to your computer and use it in GitHub Desktop.

Select an option

Save kasperpeulen/b6c43224f958f7ae9e4f to your computer and use it in GitHub Desktop.
void main() {
Map map = {
0: "not null",
1: null
};
bool test(key) => map[key] == null;
// This will remove all key/value pairs where the value is null.
map.keys.where(test).toList().forEach(map.remove);
// So the map should be of length 1 now.
assert(map.length == 1);
// prints {0: not null}
print(map);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment