I have two records in Clojurescript defined as follows:
(defrecord Html [])
(defrecord Tree [])
I need to find out the type of the item which can be defined as either of these records, how can I do this?
(def a (Html.))
(defrecord Html [])
(defrecord Tree [])
(= (type (->Html)) Html) ; true
(= (type (->Html)) Tree) ; false
(= (type (->Tree)) Html) ; false
(= (type (->Tree)) Tree) ; true
The best, host-independent way to do it is:
(instance? Html a)
This will work for any type.
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