Very awesome. So this means you can (almost) use the putAll method.
The only catch is putAll return void (WHY!)
(defn put-all
[java-map clj-map]
(doto java-map
(.putAll clj-map)))
Sean
On Nov 17, 5:29 pm, Alex Osborne <[email protected]> wrote:
> Sean Devlin wrote:
> > Okay golfers. Is there a better way to do this?
>
> > (defn put-all!
> > [java-map clj-map]
> > (do
> > (doseq [entry clj-map]
> > (.put java-map (key entry) (val entry)))
> > java-map))
>
> > user=>(put-all (java.util.HashMap. ) {:a 1 :b 2 :c 3})
> > #<HashMap {:c=3, :b=2, :a=1}>
>
> > I already tried into :)
>
> (java.util.HashMap. {:a 1 :b 2 :c 3})
> => #<HashMap {:c=3, :b=2, :a=1}>
>
> Clojure maps implement java.util.Map so you can use them where'd you'd
> (immutably) use most java maps.
--
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