Free preview.You're sampling one lesson — enroll free to unlock all 11 lessons and track your progress.
Enroll free
lesson

Types in Depth

Types in Depth

In this lesson — part of Data Deep Dive — you'll learn types in depth in Clojure and why it matters in real work.

Why it matters

Types tell you what operations make sense and catch whole classes of bugs early.

Key ideas

  • Common types: text, numbers, booleans
  • Type conversion and coercion
  • When to be explicit about types
  • Type errors and how to read them

In practice

Here's how it looks in idiomatic Clojure:

(type 42)        ; => java.lang.Long
(type 3.14)      ; => java.lang.Double
(type "hi")      ; => java.lang.String
(type :kw)       ; => clojure.lang.Keyword
(type [1 2])     ; => clojure.lang.PersistentVector
(instance? Number 42)   ; => true
(number? 42)            ; => true predicate-style check

Clojure note: Clojure is dynamically but strongly typed on the JVM, so values carry concrete Java/Clojure classes while idiomatic code dispatches on predicates (number?, string?) rather than type equality.

Try it yourself

Exercise: In Clojure, convert a number to text and back, and print both.

Recap

You now understand types in depth and can apply it in Clojure. Mark this lesson complete and continue to the next one.