store/[org.clojure/clojure "1.8.0"] clj::clojure.core/type

Official Documentation

Add notes
Arities
==================================================
   [x]

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

Source

(defn type 
  "Returns the :type metadata of x, or its Class if none"
  {:added "1.0"
   :static true}
  [x]
  (or (get (meta x) :type) (class x)))

Example 1

Edit
;; This example demonstrates how to add type information to regular clojure maps
(defn purchase-order [id date amount]
  ^{:type ::PurchaseOrder} ;metadata
  {:id id :date date :amount amount})
;; => #'user/purchase-order

(def my-order
  (purchase-order 10 (java.util.Date.) 100.0))
;; => #'user/my-order

(my-order)
;; => {:id 10, :date #<Date Sun May 15 14:29:19 EDT 2011>, :amount 100.0}

(type my-order)
;; => PurchaseOrder

Example 2

Edit
;; Checking numbers
(type 10)
;; => java.lang.Long

(type 10.0)
;; => java.lang.Double

;; Checking collections
(type [10 20])
;; => clojure.lang.PersistentVector

(type '(10 20))
;; => clojure.lang.PersistentList


;; Checking other, but somewhat intuitive, forms
(type :a)
;; => clojure.lang.Keyword

(type Thread)
;; => java.lang.Class

;; Checking a symbol
(type 'whatever)
;; => clojure.lang.Symbol

;; A surprise attack yields
(type clojure.lang.Symbol)
;; not such a surprising response
;; => java.lang.Class

;; Checking a function
(defn foo [] ("any string"))
;; => #'user/foo

(type foo)
;; => user$foo

;; Checking a macro
(type fn)
;; => user$fn

(type clojure.core/fn)
;; => java.lang.Exception: Can't take value of a macro: #'clojure.core/fn (NO_SOURCE_FILE:94)

Uses on crossclj