Reputation:
How do I make this work?
user=> (Test/main (object-array ["hello" "world"]))
ClassCastException [Ljava.lang.Object; cannot be cast to [Ljava.lang.String; user/eval21 (NO_SOURCE_FILE:21)
Upvotes: 12
Views: 3345
Reputation: 28492
(def v ["Hello" "World"])
(def a (to-array v))
EDIT: As @Jeff noted, into-array
will create typed array (String[]
) instead of Object[]
.
Upvotes: 0
Reputation: 44706
object-array
is just used to make arrays of type Object[]
. Try into-array
as you can specify the type (see here)
> (into-array String ["Awesome","Sauce"])
> #<String[] [Ljava.lang.String;@1b86d76f>
Upvotes: 20