feat: add containsKey method to Map and validate key types in subscript operations
Implement `containsKey()` native method on Map that returns a boolean indicating whether the given key exists in the map. Add `validateKey()` helper to reject non-value-type keys (objects, lists, fibers, etc.) with a clear runtime error. Refactor `wrenMapGet()` signature to return success/failure via bool and output the value through an out-parameter, enabling both `containsKey()` and the existing subscript operator to share the same key validation and lookup logic. Update `map_subscript` to return `null` instead of crashing when a key is not found. Add test cases for `containsKey` success/failure, and runtime error tests for invalid key types in subscript getter, setter, and containsKey.
This commit is contained in:
@@ -5,7 +5,11 @@ An associative collection that maps keys to values. More details [here](../maps.
|
||||
|
||||
### **clear**
|
||||
|
||||
Removes all entries
|
||||
Removes all entries from the map.
|
||||
|
||||
### **containsKey**(key)
|
||||
|
||||
Returns `true` if the map contains `key` or `false` otherwise.
|
||||
|
||||
### **count**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user