When defining a struct type and instance, I can print the value and get the "struct" implementation type:
(defstruct person :name :age)
(def p (struct person "peter" 30))
user=> p
{:name "peter", :age 30}
user=> (type p)
clojure.lang.PersistentStructMap
But is it possible to tell whether p is an instance of the struct type "person"?
See: this post in the Clojure Google Group. In general the group archives are a treasure chest...
Note: The functionality of structs is replaced by records. Then this is not a problem anymore, because records really define new type and you can check with instance?
whether something is of record of a certain 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