When applied on a map, returns a new map with new or updated key val pairs.
It can be used to add new information in existing map.
(def userData {:name "Bob" :userID 2 :country "US"})
(assoc userData :age 27) ;; { :name "Bob" :userID 2 :country "US" :age 27}
It replaces old information value if existing key is supplied.
(assoc userData :name "Fred") ;; { :name "Fred" :userID 2 :country "US" }
(assoc userData :userID 3 :age 27) ;; {:name "Bob" :userID 3 :country "US" :age 27}
It can also be used on a vector for replacing value at the specified index.
(assoc [3 5 6 7] 2 10) ;; [3 5 10 7]
(assoc [1 2 3 4] 6 6) ;; java.lang.IndexOutOfBoundsException