I am a bit confused about whether I can only use clojure multimethods on clojure structures represented by Java classes, or can I base multimethods to dispatch on structs or other properties?
It is very common to build multimethods that dispatch on the class of the first or only argument. In this case the "class" may be a Java class, a record (defrecord generates a Java class), or even an internal Clojure type like ISeq.
You can also dispatch on an arbitrary function of the args passed to the function. For example, you could compute a function and dispatch on a keyword if you wanted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With