Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Why Lisp Failed (2010). Parent comment
But you could do:
(def foo {:color "brown" :name "fred"})
(:color foo) => "brown" (:name foo) => "fred"
(foo :name) => "fred"
(defn my-func [{:keys [color name]}] (println "Color: " color) (println "Name: " name)) (my-func foo) => Color: brown Name: fred
There are no comments on this comment yet.
But you could do:
Anytime you want to get the color out you can just call the :color function and pass the map Likewise, we can call the map as the function and pass the key as the argument We also have nice ways to destructure and bind values in maps when passed as parameters to functions