Created
October 5, 2016 20:29
-
-
Save skazhy/28c53da218f4946ecddf2c96cdfacb8c to your computer and use it in GitHub Desktop.
argument map vs argument list
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
(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