The behavior of conj
with maps is:
- when provided a
MapEntry
it adds it to the map (as in associates key and value) - when provided a vector, same as 1) but it treats the 0th position of the vector as the key and the 1st position as the value to be associated with the map
- when provided other seqables than a vector, it treats it as a seqable of MapEntries, so it’s a repeated version of 1). If the seqable does not contain MapEntries then you’ll run into a ClassCastException.
The rationale for 2 could be that creating vectors is much more ergonomic than having to create MapEntry
instances.
The rationale for 3 could be that these kinds of operations work:
(conj {:a 1} (filter (fn [[k v]] (odd? v)) {:b 2 :c 3}))
;;=> {:a 1, :c 3}
Now I’ll wait for Alex to give the official answer :P.