builtins::collections

Function hash_hashkey

Source
pub fn hash_hashkey(
    environment: &mut SloshVm,
    map: &VMHashMap,
    key: Value,
) -> VMResult<Value>
Expand description

Usage: (hash-haskey hashmap key)

Checks if a key is in a hashmap.

Section: hashmap

Example: (def tst-hash {:key1 “val one” ’key2 “val two” “key3” “val three” \S “val S”}) (test::assert-equal 4 (len (hash-keys tst-hash))) (test::assert-true (hash-haskey tst-hash :key1)) (test::assert-true (hash-haskey tst-hash ’key2)) (test::assert-true (hash-haskey tst-hash “key3”)) (test::assert-true (hash-haskey tst-hash \S)) (test::assert-false (hash-haskey tst-hash ’key1)) (test::assert-false (hash-haskey tst-hash :key2)) (test::assert-false (hash-haskey tst-hash “keynone”)) (hash-remove! tst-hash :key1) (test::assert-false (hash-haskey tst-hash :key1)) (set! tst-hash :key1 “val one b”) (test::assert-true (hash-haskey tst-hash :key1))