You're viewing version 1.2.0 of instance?. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

instance?

clojure.core

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

3 Examples top

  • user=> (instance? Long 1)
    true
    user=> (instance? Integer 1)
    false
    user=> (instance? Number 1)
    true
    user=> (instance? String 1)
    false
    user=> (instance? String "1")
    true
    
  • 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
  • ;; Some things are more than what they seem to be at first glance
    user=> (instance? clojure.lang.IFn +)
    true
    user=> (instance? clojure.lang.Keyword :a)
    true
    user=> (instance? clojure.lang.IFn :a)
    true
    user=> (instance? clojure.lang.IFn {:a 1})
    true
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Comments top

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