How to dispatch a multimethod on the type of an array
Posted
by Arthur Ulfeldt
on Stack Overflow
See other posts from Stack Overflow
or by Arthur Ulfeldt
Published on 2010-05-06T16:58:31Z
Indexed on
2010/05/06
17:38 UTC
Read the original article
Hit count: 183
clojure
I'm working on a multimethod that needs to update a hash for a bunch of different things in a sequence. Looked fairly straitforward until I tried to enter the 'type of an array of X'.
(defmulti update-hash #(class %2))
(type (byte 1))
=> java.lang.Byte
(defmethod update-hash java.lang.Byte [md byte]
(. md update byte))
(type (into-array [ (byte 1)]))
=> [Ljava.lang.Byte;
(defmethod update-hash < WHAT GOES HERE > [md byte]
© Stack Overflow or respective owner