Permalink
Browse files

create java objs that take java interfaces with clojure objs

  • Loading branch information...
1 parent d762764 commit ea5a526222da3046c6134bd3a4fb7d62392479f7 Jay Fields committed Dec 24, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/clojure/interop/core.clj
@@ -1,4 +1,11 @@
(ns interop.core)
(defn print-string [arg]
- (println (String. arg)))
+ ;;; pass a Clojure vector where Java expects a java.util.Collection
+ (println (java.util.HashSet. ["1" "2"]))
+
+ ;;; pass a Clojure map where Java expects a java.util.Map
+ (println (java.util.LinkedHashMap. {1 "1" 2 "2"}))
+
+ ;;; pass a Clojure function where Java expects a Runnable
+ (println (Thread. (fn [] (println "clojure fns are runnables (and callables)")))))

0 comments on commit ea5a526

Please sign in to comment.