May 2018
Beginner to intermediate
290 pages
6h 43m
English
While a map will let you use virtually anything for a key, Clojure programmers commonly use keywords as keys. Like strings, numbers, and Booleans, keywords are a basic data type that comes packaged with Clojure. Syntactically, a keyword literal starts with a colon and then follows the same rules as symbols. Thus any of the following are fine keywords:
| | :title |
| | :author |
| | :published |
| | :word-count |
| | :preface&introduction |
| | :chapter-1-and-2 |
You can look at keywords as a sort of subspecies of a string: both are just a sequence of characters. The reason we have both keywords and strings is that, like vectors and lists, they are good at different things. Strings are data. If you read an author’s name or title from a file, you’ll probably store ...
Read now
Unlock full access