Strings

A String can contain any simple value such as numbers, letters or special characters.

A string is surrounded with double quotation marks, "".

Strings are used a lot for content (e.g. blogs), user interfaces (e.g. menus) as well any other simple data (e.g. names, email addresses).

Example strings

;; writing a string.  A string just evaluates to itself.
"Hello, World!"

;; create a string from other strings and numbers with the str function
(str "It's lunchtime in"
     " "
     1
     " "
     "hour" )

;; Strings can include special characters if you put the `\` character before them
(str "I am a"
     " "
     "\'functional \'"
     " "
     "programmer")

Working with strings

There are many functions that work with strings, especially in the clojure.string library


Hint

Be careful if you copy/pasting Clojure code from a website that uses the stylised double quotes. These stylised quotes are actually a different character, so your string would not evaluate correctly.

results matching ""

    No results matching ""