2

I am using a ClojureScript browser REPL in SublimeText, and there are certain Java methods included:

(.toUpperCase "blub") --> "BLUB"

However, I'd like to use .toBinaryString, but java.lang.Integer is not included and I'm not sure how to import it. (import %) doesn't work no matter what format I use for %; it always throws:

cannot read property "call" of undefined

My question is two parts; how can I see what Java libs are included in the REPL, and how do I use other libraries that aren't included?

1 Answer 1

3

ClojureScript compiles to JavaScript, the toUpperCase method that you called comes from JavaScript String not Java's. The only time in ClojureScript that you could use Java is when you're writing a macro. But that is because macros are written in Clojure, not in ClojureScript.

This is a list of the differences between Clojure and ClojureScript.

Sign up to request clarification or add additional context in comments.

2 Comments

I've read that and several articles on cljs-js interop, but whenever I try to use a js library (prototype.js in this case for the toString function), I get an error. This is after including a :libs and :foreign-libs clause in my project.clj file and requiring it in the namespace. I don't understand it.
Please create another question about that problem, or search in stackoverflow. Your original question was about Java interop, no?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.