Skip to content

cljr destructure keys

Magnar Sveen edited this page Apr 3, 2015 · 1 revision

dk Destructure keys

Given this:

(defn- render-recommendation [rec]
  (list [:h3 (:title rec)]
        [:p (:by rec)]
        [:p (:blurb rec) " "
         (render-link (:link rec))]))

I place the cursor on rec inside [rec] and do cljr-destructure-keys:

(defn- render-recommendation [{:keys [title by blurb link]}]
  (list [:h3 title]
        [:p by]
        [:p blurb " "
         (render-link link)]))

If rec had still been in use, it would have added an :as clause.

For now this feature is limited to top-level symbols in a let form. PR welcome.