1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/docs/lib3x-hashmap_put.md

24 lines
662 B
Markdown
Raw Normal View History

2021-03-09 17:11:02 +08:00
# hashmap_put
2021-04-10 16:30:04 +08:00
Puts a key/value pair to a [util/map/hashmap](https://openhome.cc/eGossip/OpenSCAD/lib3x-hashmap.html).
2021-03-09 17:11:02 +08:00
**Since:** 3.0
## Parameters
- `map` : The original map.
2021-09-09 16:31:42 +08:00
- `key` : The specified key.
- `value` : The specified value.
- `eq` : A equality function. If it's ignored, use `==` to compare elements.
- `hash` : A hash function. If it's ignored, convert each element to a string and hash it.
2021-03-09 17:11:02 +08:00
## Examples
2022-06-06 13:11:46 +08:00
use <util/map/hashmap.scad>
use <util/map/hashmap_put.scad>
use <util/map/hashmap_get.scad>
2021-03-09 17:11:02 +08:00
m1 = hashmap([["k1", 10], ["k2", 20], ["k3", 30]]);
m2 = hashmap_put(m1, "k4", 40);
assert(hashmap_get(m2, "k4") == 40);