- Clojure, the core data structures aren't mutable
Clojure has two types of expressions atoms and collections
Atoms represent Primitive Types in other languages, like:
Numbers, Strings, Boolean, Nil, Symbols, Keywords
-
Numbers
2
1.5
-
Strings
A valid string example with""
(println "Hello World") => Hello World (println "\"Hello World\"") => "Hello World"
Invalid String example with
''
(println 'Hello World') => clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: World' in this context, compiling:(null:5:1)
Note: Clojure doesn't have string interpolation
-
Boolean
true
false
-
Nil - Clojure’s name for no-value
nil
-
Symbols (Not to be confused with Ruby's symbols)
Symbols in clojure are like identifiers to refer to something like variables in other laguages. As clojure does not have variables. -
Keywords (They bind to themseleves)
Primarily used as keys in hashes/maps
:key
:1234