I evaluated the following elisp code in ielm:
(setq foo-hash (make-hash-table))
(puthash "location" "house" foo-hash)
(defun foo-start ()
(interactive)
(message (gethash "location" foo-hash)))
However when i run (foo-start) or (gethash "location" foo-hash) i get only nil echoed. Entering just foo-hash in ielm echoes: #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8 data ("location" "house"))
Is that a bug or i am doing something wrong?
Emacs version: 24.0.95.1
Hash tables in elisp use
eqlfor comparison by default. Strings won’t be equal witheqlunless they’re the same object. You probably want to useequal, which compares the contents of the strings. Create your hash table with this: