Clojure for Beginners: Clojure Maps — assoc, dissoc, update & get-in
Video: Clojure Maps — assoc, dissoc, update & get-in | Episode 9 by CelesteAI
Watch full page →Clojure Maps — assoc, dissoc, update & get-in
Maps are everywhere in Clojure. They replace objects, structs, and dictionaries from other languages — all with one simple syntax and a handful of functions.
Code
;; Episode 9: Maps
;; Clojure for Beginners in Neovim
;; Create a user map with keyword keys
(def user {:name "Ada" :age 30 :lang "Clojure"})
(println "User:" user)
;; Access with get and keyword-as-function
(println "Name:" (get user :name))
(println "Age:" (:age user))
;; assoc adds or updates a key
(def user2 (assoc user :email "ada@example.com"))
(println "With email:" user2)
;; dissoc removes a key
(println "Without lang:" (dissoc user :lang))
;; update applies a function to a value
(println "Birthday:" (update user :age inc))
;; Original unchanged — maps are immutable
(println "Original:" user)
;; Nested maps with get-in
(def profile {:name "Ada" :address {:city "London" :zip "SW1"}})
(println "City:" (get-in profile [:address :city]))
Key Points
Watch the video above for a full walkthrough — every keystroke is shown so you can code along.
Student code: GitHub