(rontolisp) docs
← Numbers and predicates

instance?

(instance? Class x)

true when x is an instance of the class, like the oracle's isInstance. A class or interface answers for every kind of value whose oracle class is or implements it: java.util.List for a vector, a list or a lazy seq, java.util.Map for a map or a record, clojure.lang.IFn for a function, keyword, symbol, map, set, vector or var, Comparable for a string, number, keyword or vector, java.io.Writer for *out*. Object is every value but nil. A known record/deftype name tests the dispatch tag. A protocol's interface (user.P, the namespace and name munged like the oracle's: my_app.core.my_p) is true of a record, deftype or reify whose body names the protocol, with methods or none; an extend-type or extend-protocol target is not (satisfies? is). A throwable class (Exception, IllegalArgumentException, clojure.lang.ExceptionInfo, a dotted or imported one) tests an exception or a runtime error by its class -- the class class answers or a subclass of it. On the interpreter and the JVM a host object answers by its host class, so (instance? java.io.File (java.io.File. "x")) and (instance? Number (java.math.BigDecimal. "1")) are true; a class no value here has (java.io.File of a Clojure value, Integer) answers false, and a name no class has is unknown name.