From 01e138ebd47627419805a4375988970496446d6f Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 1 Apr 2015 21:37:59 -0500 Subject: [PATCH] Add Type of Anything as a clojure til. --- README.md | 1 + clojure/type-of-anything.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 clojure/type-of-anything.md diff --git a/README.md b/README.md index d409c75..bf20e66 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). ### clojure - [Splitting On Whitespace](clojure/splitting-on-whitespace.md) +- [Type of Anything](clojure/type-of-anything.md) ### git diff --git a/clojure/type-of-anything.md b/clojure/type-of-anything.md new file mode 100644 index 0000000..be9b3c9 --- /dev/null +++ b/clojure/type-of-anything.md @@ -0,0 +1,25 @@ +# Type of Anything + +You can get the type of anything with the `type` function. Because Clojure +is built on Java, many of these types may be types you recognize form Java. + +Boot up the repl to try some of these out: + +```clojure +> (type 5) +; java.lang.Long +> (type 5.2) +; java.lang.Double +> (type 5/4) +; clojure.lang.Ratio +> (type (int 2)) +; java.lang.Integer +> (type "hello, world!") +; java.lang.String +> (type [1 2 3]) +; clojure.lang.PersistentVector +> (type '(1 2 3)) +; clojure.lang.PersistentList +``` + +[source](https://aphyr.com/posts/302-clojure-from-the-ground-up-basic-types)