instance?

clojure.core

  • (instance? c x)
Evaluates x and tests if it is an instance of the class
c. Returns true or false

2 Examples top

  • user=> (instance? Integer 1)
    true
    user=> (instance? Number 1)
    true
    user=> (instance? String 1)
    false
  • user=> (def al (new java.util.ArrayList))
    #'user/al
    user=> (instance? java.util.Collection al)
    true
    user=> (instance? java.util.RandomAccess al)
    true
    user=> (instance? java.lang.String al)
    false
    user=>
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:135 top

(def
 ^{:arglists '([^Class c x])
   :doc "Evaluates x and tests if it is an instance of the class
    c. Returns true or false"
   :added "1.0"}
 instance? (fn instance? [^Class c x] (. c (isInstance x))))
Vars in clojure.core/instance?:
Used in 0 other vars

Comments top

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