Created
February 13, 2011 14:59
-
-
Save rik0/824739 to your computer and use it in GitHub Desktop.
let-array clojure macro used to destructure a Java array.
This file contains 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 -initialize [this params] | |
(let-array [ | |
{:keys [is-starting-node connections-on-spawn starting-nodes] | |
:or {is-starting-node false} | |
:as options} params] | |
(dosync (alter (.state this) merge options)) | |
true)) |
This file contains 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
(defmacro let-array [[{keys :keys defaults :or options :as} params] & body] | |
`(let [{:keys ~keys :or ~defaults :as ~options} | |
(apply hash-map (interleave (map keyword '~keys) ~params))] | |
~@body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment