albusshin
albusshin

Reputation: 4010

Differences between type and class in Clojure

What are the differences between type and class in Clojure?

(type "") => java.lang.String
(class "") => java.lang.String
(type 1) => java.lang.Long
(class 1) => java.lang.Long

Upvotes: 16

Views: 1042

Answers (1)

albusshin
albusshin

Reputation: 4010

According to ClojureDocs

type

type clojure.core

(type x)

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

class

class clojure.core

(class x)

Returns the Class of x

So, basically if there're metadata inside x, type should return its :type metadata, otherwise they're the same thing.

Upvotes: 19

Related Questions