I have the following record type that I am trying to test:
(defrecord FirstOrderState [datum matrix]
State
;; implementation goes here ...
)
I am trying to branch based on the above type, but am not getting the results I need
(def state (->FirstOrderState datum matrix))
(= (type state) composer.algorithm.markov.state.FirstOrderState)
=> false
However, looking at the type of state
confirms that it should match:
(type state)
=> composer.algorithm.markov.state.FirstOrderState
This seems like it should work, as a similar check results in true
:
(= (type []) clojure.lang.PersistentVector)
=> true
What is it that I am missing here? Using the below hack provides a solution, but not very elegant:
(= (str (type state)) (str composer.algorithm.markov.state.FirstOrderState))
=> true
My first guess would be that you have reloaded the namespace containing the definition of the record type and that
state
is defined elsewhere (possibly at the REPL), and socomposer.algorithm.markov.state.FirstOrderState
now refers to a different class from the one it used to at the time whenstate
was created.Demo at the REPL: