Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: Release 1.2, Release 1.3, Release 1.4
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:None
-
Patch:Code and Test
-
Approval:Ok
Description
https://groups.google.com/forum/?fromgroups=#!topic/clojure/k2R4OdPUCzg
Suggested by Ambrose Bonnaire-Sergeant:
I think assoc should throw an error when applied with uneven arguments.
Currently, the "missing" value is just replaced with nil.
(assoc {} :a 1 :b)
;=> {:a 1, :b nil}
Patch clj-1052-assoc-should-throw-exc-if-missing-val-patch1.txt dated Aug 29 2012 makes assoc throw an IllegalArgumentException if more than one key is given, but the last key has no value. It includes a few simple test cases with correct and incorrect arguments to assoc.