cast

added
1.0

ns
clojure.core

type
function

(cast c x)

Throws a ClassCastException if x is not a c, else returns x.

                ;; 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