feat: implement map clear method to remove all entries

Add DEF_NATIVE(map_clear) that frees the underlying entries array and resets
capacity and count to zero, returning null. Register the "clear" method on
the Map class in wrenInitializeCore and include a test verifying the map is
emptied and the return value is null.
This commit is contained in:
Bob Nystrom
2015-01-25 16:39:44 +00:00
parent 2ec0a8aef9
commit 56123c71e3
2 changed files with 18 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
var a = {1: 1, 2: 2, 3: 3}
a.clear
IO.print(a) // expect: {}
IO.print(a.count) // expect: 0
// Returns null.
IO.print({1: 2}.clear) // expect: null