4 ms·
Clojure: Keyword argument functions now also accept maps
- nickik 6y agoNeat. I have been a fan of Keyword arguments for a long time. Dylan does it well too. I mostly didn't do this for my Clojure code, because I didn't want to use any of the libraries that do it. Simply because to many times there is an issue with libs like that in the long term and are hard to read. You also run into an issue of how far to go, how about adding defaults, constraints and so on. Having a simple standard way in Clojure core was something I hoped would happen in a long time.
- lincpa 6y agoadding defaults: (def ^:pravite defa-opt-map {:a 0 :b 9}) (defn f [opt-map] (let [opt-map (merge defa-opt-map opt-map) {:keys [a b]} opt-map] ; doing something ))
- machawinka 6y agoComing from Python, I always wondered why this was not the default behavior.
- deleted 6y ago[deleted]