Skip to content

@jsofra /optional-config.clj
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Config using optional named parameters
(def ^:dynamic *config* nil)
(defn save [data & {:keys [config] :or {config *config*}}]
(println (format "Saved %s with %s" data config)))
;; => (save {:a 5 :b 6} :config {:some :config})
;; Saved {:a 5, :b 6} with {:some :config}
;; nil
;; => (binding [*config* {:some :config}] (save {:a 5 :b 6}))
;; Saved {:a 5, :b 6} with {:some :config}
;; nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.