The simplest solution probably captures the class programmatically with reflection.
(defprotocol do-a-thing (print-thing [thing])) (extend-protocol do-a-thing (class (float-array 0)) (print-thing [_] (println "it a float array")))
Java arrays follow odd names. For example, the float array has the value [F If you try to use it directly in the REPL, it will suffocate from the unrivaled [ . However, you can still use this name, for example, Class/forName .
(defprotocol do-another-thing (print-another-thing [thing])) (extend-protocol do-another-thing (Class/forName "[F") (print-another-thing [_] (println "it still a float array")))
In this article, we will take a closer look at array classes.
source share