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.
8 lines
155 B
Plaintext
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
|