ClojureDocs

Nav

Namespaces

cast

clojure.core

Available since 1.0 (source)
  • (cast c x)
Throws a ClassCastException if x is not a c, else returns x.
1 Example
;; Cast doesn't change the type of the input - it just throws an exception if it's the wrong type
;; Since Long is a subclass of Number
user=> (cast Number 1)  
1
user=> (type (cast Number 1))
java.lang.Long
See Also

Returns the :type metadata of x, or its Class if none

Added by phreed
0 Notes
No notes for cast