Reputation: 517
Ho can I have this type matching work. (I am using clojure.core.match/match
). Or is multimethod
the only way to go.
(let [x "1.2"]
(match [(read-string x)]
[^java.lang.Long l] :long
[^java.lang.Double d] :double
:else :string))
>> :long
Thanks
Upvotes: 0
Views: 299
Reputation: 1718
you can do it with a normal condp
(let [x "1.2"]
(condp = (type (read-string x))
java.lang.Long :long
java.lang.Double :double
:string))
Upvotes: 3