> The only catch is putAll return void (WHY!)

Apparently Java people like having more LOC :)

> (defn put-all
>  [java-map clj-map]
>  (doto java-map
>    (.putAll clj-map)))

Note that this isn't limited to Clojure maps, so 'clj-map' is probably  
a bad variable name. It works just as well for combining two Java maps.

(import 'java.util.Map 'java.util.HashMap)

(defn put-all
  [#^Map java-map #^Map clj-map]
  (doto java-map
    (.putAll clj-map)))


user=> (put-all (HashMap. {:foo :bar}) (HashMap. {:bar :baz}))
#<HashMap {:bar=:baz, :foo=:bar}>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to