Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between type and class in Clojure

Tags:

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
like image 376
albusshin Avatar asked Mar 25 '14 22:03

albusshin


1 Answers

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.

like image 183
albusshin Avatar answered Sep 22 '22 17:09

albusshin