16

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 

1 Answer 1

19

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.

Sign up to request clarification or add additional context in comments.

1 Comment

What is a case where the type metadata wouldn't be there? And what adds it?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.