hashtable-ref - get a value from a hashtable
(import (rnrs)) ;R6RS
(import (rnrs hashtables)) ;R6RS
(hashtable-ref hashtable key default)
Returns the value in
does not contain an association for
Returns a single object; either a value from an association in
or the object
(define ht (make-eq-hashtable))
(hashtable-set! ht 'foo 'bar)
(hashtable-ref ht 'foo #f) => bar
(hashtable-ref ht 'bar #f) => #f
This procedure is unique to R6RS. Similar procedures exist in
SRFI-69 and SRFI-125.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
should be a hashtable and
should be in the domain of the hashtable's hash and equal functions.
This procedure first appeared in R6RS. An equivalent procedure already
existed in SRFI-69 under the name
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
The following code pattern does not work if the hashtable's
keys can be associated with the false object.
(cond ((hashtable-ref ht key #f) =>
(... do something with value ...)))
... assume key is not in ht ...))
to get around this problem.
Markup created by unroff 1.0sc, March 04, 2023.