May 2018
Beginner to intermediate
290 pages
6h 43m
English
In addition to the plain vanilla version of let that we’ve looked at so far, Clojure comes packaged with a couple of handy variations. The most commonly used of these is probably if-let. As you might guess from the name, if-let is an if and a let rolled into one. To see if-let in action, imagine that we decide to represent anonymous books with our now-familiar book map, sans the :author key:
| | (def anonymous-book |
| | {:title "Sir Gawain and the Green Knight"}) |
| | |
| | (def with-author |
| | {:title "Once and Future King" :author "White"}) |
Now imagine we needed to write a function that will return the uppercase version of the author’s name, or nil if there is no author. The twist is that we need to avoid computing the uppercase ...
Read now
Unlock full access