Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes "java.lang.IllegalArgumentException: No value supplied for key"?

I have code of the shape

(let [{foo :foo} (make-foo)] ...)

This code occasionally emits a java.lang.IllegalArgumentException: No value supplied for key: {:foo "foo" :other "other"}.

I've seen Clojure : "java.lang.IllegalArgumentException: No value supplied for key:" when I changed require, however I haven't changed the require of my program since it last worked.

What are the possible causes for the "No value supplied for key" exception?

like image 452
user12341234 Avatar asked Dec 07 '22 16:12

user12341234


1 Answers

This happens when you try to create a map from an odd number of key/value entries: the last key is missing a value. One way this can happen is when destructuring a non-map collection but treating it as a map, since this implicitly creates a map from the collection for you before destructuring it as an ordinary map.

like image 179
amalloy Avatar answered Dec 11 '22 09:12

amalloy