Skip to content

Instantly share code, notes, and snippets.

@rik0
Created February 13, 2011 14:59
Show Gist options
  • Save rik0/824739 to your computer and use it in GitHub Desktop.
Save rik0/824739 to your computer and use it in GitHub Desktop.
let-array clojure macro used to destructure a Java array.
(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))
(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