4 ms·
> I wonder what Clojure programmers do here. About the same. (defn message [text & {:keys [style color]}] ...) (message "Text" :style :bold :co
by jamii 13y ago
> I wonder what Clojure programmers do here.
About the same.
(defn message [text & {:keys [style color]}]
...)
(message "Text" :style :bold :color :red)
Because typing those extra two brackets is apparently too much trouble.
- ANTSANTS 13y agoI can't say I expected it to look like that.
- cgag 13y agoI would just accept the hash, I think a lot of us prefer it to the pseudo keyword args. (defn message [text {:keys [style color]}] ...) (message "Text" {:style :bold :color :red}) To the person asking, that {:keys [style color]} is destructuring, it's not required, but it's nice, it's equivalent to doing: (defn message [text opts] (let [style (:style opts) color (:color opts)] ...))