Skip to content

Instantly share code, notes, and snippets.

@kineticz
Created January 24, 2015 19:20
Show Gist options
  • Select an option

  • Save kineticz/f33351f657ef9be7e17d to your computer and use it in GitHub Desktop.

Select an option

Save kineticz/f33351f657ef9be7e17d to your computer and use it in GitHub Desktop.
Destructuring nested maps in clojure, both versions work.
;; version 1
(def game {:world {:tiles 5}})
(defn get-tiles
[{{:keys [tiles]} :world :as game}]
(println game)
(println tiles))
(get-tiles game)
;; version 2
(def game {:world {:tiles 5}})
(defn get-tiles
[{{tiles :tiles} :world :as game}]
(println game)
(println tiles))
(get-tiles game)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment