Created
January 24, 2015 19:20
-
-
Save kineticz/f33351f657ef9be7e17d to your computer and use it in GitHub Desktop.
Destructuring nested maps in clojure, both versions work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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