On Sep 20, 11:04 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> I needed an empty array of Strings to pass to a Java function. The
> first place I considered was "into-array", but without an array
> element to work with, it returns an array of Object.
>
> I suggest that into-array be extended to allow a second argument that
> gives the type of the elements in the destination array explicitly.
> This would be useful for the case I'm after (an empty array), but also
> in general if one has a seq of objects compatible with a destination
> type, but where the first item in the seq may or may not be exactly
> that type.
>
> Proposed doc:
> -------------------------
> clojure/into-array
> ([aseq] [aseq type])
> Returns a typed array containing the contents of aseq. If type
> is not provided, it defaults to the class of the first item in aseq.
> All items in aseq must be of a class compatible with the
> destination type.
>
> Pending that proposed change, I came up with this:
>
> (java.lang.reflect.Array/newInstance String 0)
>
Hmm.. there is already make-array for the latter:
(make-array String 0)
find-doc is your friend :)
As far as into-array taking a type, I'm fine with that, but the type
should come first.
Rich
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---