Difference between revisions of "Map"
Jump to navigation
Jump to search
(Added base methods for the map class) |
m (Adjusted Pop definition) |
||
| Line 15: | Line 15: | ||
| len || Returns the number of key/value pairs contained in the map | | len || Returns the number of key/value pairs contained in the map | ||
|- | |- | ||
| − | | pop || Removes | + | | pop || Removes a key/value pair from the map and returns the key. There is no guarantee which pair gets removed. |
|- | |- | ||
| push ''key'' || Adds the ''key'' to the map and assigns a value of 1 | | push ''key'' || Adds the ''key'' to the map and assigns a value of 1 | ||
Latest revision as of 07:31, 2 September 2025
map is one of the core data types in MiniScript.
Methods
| Method | Description |
|---|---|
| hasIndex(key) | Returns true if the map contains key |
| indexes | Returns a list of the map keys |
| indexOf(value, after) | Returns the key of the first occurrence of value in the map, or null if not found. Does not search inheritance chain.
|
| len | Returns the number of key/value pairs contained in the map |
| pop | Removes a key/value pair from the map and returns the key. There is no guarantee which pair gets removed. |
| push key | Adds the key to the map and assigns a value of 1 |
| pull | Same as pop. |
| shuffle | Mutates the map by randomly re-ordering the values assigned to each key within the map |
| sum | Returns the sum of all numeric values in the map |
| remove key | Removes the key/value pair at key |
| replace oldValue, newValue, maxCount | Mutates the map by replacing occurrences of oldValue with newValue at most maxCount, if specified. If maxCount is omitted it replaces all occurrences. |
| values | Returns a list values within the map |
See also
- mapUtil - for additional functions on a list