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:
@@ -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
|
||||
Reference in New Issue
Block a user