Last active
August 29, 2015 14:26
-
-
Save kasperpeulen/3e64e4792c228993906f to your computer and use it in GitHub Desktop.
dart.core_Map.remove
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| Map map = { | |
| 0: "not null", | |
| 1: null | |
| }; | |
| bool test(key) => map[key] == null; | |
| //test | |
| // 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