Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Is String Formatting Causing a Casting Exception?

Tags:

clojure

Why does (String/format "%8s" (Integer/toBinaryString 6)) result in a java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object casting exception?

like image 890
Ari Avatar asked Oct 04 '11 04:10

Ari


1 Answers

I don't know Clojure, but I suspect that's trying to call the method as if it were the Java:

String.format("%8s", Integer.toBinaryString(6));

but without the varargs support. I suspect you want:

(String/format "%8s" (into-array Object (Integer/toBinaryString 6)))

See this mailing list thread for more information from people who actually do know Clojure :)

like image 88
Jon Skeet Avatar answered Sep 22 '22 23:09

Jon Skeet