3

Just curious on why a string in Clojure isn't of type clojure.string, and instead is java.lang.String. It seems a bit odd that I need to require clojure.string to access the native Clojure string functions?

1 Answer 1

6

Because java.lang.String is immutable and doesn't break interoperability with Java. The functions in clojure.string can be mostly considered as a convenience layer on top of already existing functionality in the JDK and/or clojure.core.

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

1 Comment

Also worth noting for the asker that clojure.string isn't a type, but a namespace, and java.lang.String is a type contained within java.lang.

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.