On Fri, Jun 19, 2009 at 2:13 PM, pmf<phil.fr...@gmx.de> wrote:
> On Jun 19, 1:31 pm, Josip Gracin <josip.gra...@gmail.com> wrote:
>> How do I dispatch on Java primitive array? I mean, my dispatch
>> function is 'class' and I'd like to add method for byte arrays.
>
> A not very elegant way would be to simply use (class (make-array Byte/
> TYPE 0)) as dispatch value, as in the following:
>
> (defmulti whatever
>  "Blah"
>  class)
>
> (defmethod whatever
>  (class (make-array Byte/TYPE 0)) ; dispatch value
>  [arg]
>  (println arg))
>
> (whatever (make-array Byte/TYPE 0)) ; succeeds

Thanks!

Another way suggested by Rich on IRC is (Class/forName "[B").

--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to