Skip to content

Instantly share code, notes, and snippets.

@skazhy
Created October 5, 2016 20:29
Show Gist options
  • Save skazhy/28c53da218f4946ecddf2c96cdfacb8c to your computer and use it in GitHub Desktop.
Save skazhy/28c53da218f4946ecddf2c96cdfacb8c to your computer and use it in GitHub Desktop.
argument map vs argument list
(defn arg-map [{:keys [foo]}] foo)
(arg-map {:foo 1}) ; 1
(arg-map {:foo 1 :foo 2}) ; Compiler Exception
; apply hash-map is executed internally, so fun things happen:
(defn kwargs [& {:keys [foo]}] foo)
(kwargs :foo 1) ; => 1
(kwargs :foo 1 :foo 2) ; => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment