Files
wren/test/map/clear.wren
T
Bob Nystrom 56123c71e3 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.
2015-01-25 16:39:44 +00:00

8 lines
155 B
Plaintext

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