satisfies?

clojure.core

  • (satisfies? protocol x)
Returns true if x satisfies the protocol

1 Example top

  • (ns foo)
    
    (defprotocol Foo
      (foo [this]))
    
    (defprotocol Bar
      (bar [this]))
    
    (extend java.lang.Number
      Bar
      {:bar (fn [this] 42)})
    
    (extend java.lang.String
      Foo
      {:foo (fn [this] "foo")}
      Bar
      {:bar (fn [this] "forty two")})
    
    (satisfies? Foo "zam") ; => true
    (satisfies? Bar "zam") ; => true
    (satisfies? Foo 123)   ; => false
    (satisfies? Bar 123)   ; => true
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core_deftype.clj:481 top

(defn satisfies? 
  "Returns true if x satisfies the protocol"
  {:added "1.2"}
  [protocol x]
  (boolean (find-protocol-impl protocol x)))
Vars in clojure.core/satisfies?:
Used in 0 other vars

Comments top

No comments for satisfies?. Log in to add a comment.