Phylth
Phylth

Reputation: 368

How to import Java class in ClojureScript?

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?

Upvotes: 2

Views: 1100

Answers (1)

Rodrigo Taboada
Rodrigo Taboada

Reputation: 2727

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.

Upvotes: 3

Related Questions