May 2018
Beginner to intermediate
290 pages
6h 43m
English
Like everything else in programming maps, sets and keywords have their pitfalls. The good news about keywords is that they’re so simple it’s hard to go wrong with them. Mainly you just have to keep in mind that keywords are not strings. The keyword :title is not, for example, the same as the string "title". Thus with a keyword-based map like this:
| | (def book |
| | {:title "Oliver Twist" |
| | :author "Dickens" |
| | :published 1838}) |
doing this:
| | (book "title") |
will return you exactly nothing (well, a nil), whereas doing this:
| | (assoc book "title" "Pride and Prejudice") |
will return a four-entry map:
| | {:title "Oliver Twist" |
| | :author "Dickens" |
| | :published 1838 |
| | "title" "Pride and Prejudice"} |
There are also some ...
Read now
Unlock full access