mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Type of Anything as a clojure til.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
25
clojure/type-of-anything.md
Normal file
25
clojure/type-of-anything.md
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user