effect-io-ai

Package: effect
Module: HashMap

HashMap.set

Sets the specified key to the specified value using the internal hashing function.

Example (Setting a value)

import { HashMap } from "effect"

const map1 = HashMap.make(["a", 1])
const map2 = HashMap.set(map1, "b", 2)

console.log(HashMap.size(map2)) // 2
console.log(HashMap.get(map2, "b")) // Option.some(2)

// Original map is unchanged
console.log(HashMap.size(map1)) // 1

Signature

declare const set: { <K, V>(key: K, value: V): (self: HashMap<K, V>) => HashMap<K, V>; <K, V>(self: HashMap<K, V>, key: K, value: V): HashMap<K, V>; }

Source

Since v2.0.0