java

2020-09-23T20:03:36.001200Z

is there some sort of extra hinting I have to do to handle reifying a Consumer of a generic type?

2020-09-23T20:03:52.001400Z

I keep on getting class cast errors

2020-09-23T20:03:54.001600Z

Syntax error (ClassCastException) compiling at (/tmp/form-init17042598140599140008.clj:1:74). class aishub.core$consumer$reify__166 cannot be cast to class [Ljava.util.function.Consumer; (aishub.core$consumer$ reify__166 is in unnamed module of loader clojure.lang.DynamicClassLoader @29f0802c; [Ljava.util.function.Consumer; is in module java.base of loader 'bootstrap')

2020-09-23T20:04:37.001700Z

(defn ^Consumer consumer [] (reify Consumer (accept [this t] (println t))))

2020-09-23T20:04:44.001900Z

with something calling (NMEAMessageHandler. "LS" (consumer) later

alexmiller 2020-09-23T20:07:11.002100Z

you'll want the type hint before the [], not after defn

2020-09-23T20:25:59.002300Z

that's a good catch! but I'm still getting the same error

2020-09-23T20:32:11.002500Z

maybe a better practice to do a gen-class w/ :implements?

alexmiller 2020-09-23T22:01:43.002700Z

shouldn't matter unless there's more to it than what you've shown