effect-io-ai

Package: effect
Module: MutableHashMap

MutableHashMap.get

Looks up a key in the MutableHashMap safely.

When to use

Use to safely read a MutableHashMap value for a key as an Option.

Details

Returns Some(value) when an equal key is present and None when the key is absent.

Example (Getting a value)

import { MutableHashMap } from "effect"

const map = MutableHashMap.make(["key1", 42], ["key2", 100])

console.log(MutableHashMap.get(map, "key1")) // Some(42)
console.log(MutableHashMap.get(map, "key3")) // None

// Pipe-able version
const getValue = MutableHashMap.get("key1")
console.log(getValue(map)) // Some(42)

See

Signature

declare const get: { <K>(key: K): <V>(self: MutableHashMap<K, V>) => Option.Option<V>; <K, V>(self: MutableHashMap<K, V>, key: K): Option.Option<V>; }

Source

Since v2.0.0