feat: add remove() method to Map class with native implementation and tests

This commit is contained in:
Bob Nystrom
2015-01-26 01:42:36 +00:00
parent a83205ef89
commit f647680184
7 changed files with 142 additions and 46 deletions
+18
View File
@@ -0,0 +1,18 @@
var map = {
"one": 1,
"two": 2,
"three": 3
}
IO.print(map.count) // expect: 3
IO.print(map.remove("two")) // expect: 2
IO.print(map.count) // expect: 2
IO.print(map.remove("three")) // expect: 3
IO.print(map.count) // expect: 1
// Remove an already removed entry.
IO.print(map.remove("two")) // expect: null
IO.print(map.count) // expect: 1
IO.print(map.remove("one")) // expect: 1
IO.print(map.count) // expect: 0