Clojure: destructure and rename with {:keys [...]}

Use destructuring without :keys:

(let [{my-response :response} {:response 1}]
  (println my-response))

{:keys [response]} is syntactic sugar for {response :response}.


Here you go:

(let [{:keys [response]} {:response 1}
      my-response response]
   (println my-response))

For a better answer refer to https://stackoverflow.com/a/57592661/2757027.

This answer is much closer to the question, but technically not single step. but this doesn't involve any complicated de-structuring.

Tags:

Clojure