zcaudate
zcaudate

Reputation: 14258

how to check if a record implements a particular protocol?

I have a protocol:

(defprotocol IInterval
  (-duration  [in]))

and a record that implements it:

(defrecord Interval [start end]
  IInterval
  (-duration  [_] (- end
                     start)))

if I create (def i1 (Interval 0 1000))

how would I be able to the method implements? where:

(implements? IInterval i1) => true

Upvotes: 5

Views: 869

Answers (1)

Lee
Lee

Reputation: 144136

You can use satisfies?:

(satisfies? IInterval i1)

Upvotes: 9

Related Questions