May 2018
Beginner to intermediate
290 pages
6h 43m
English
Real-life Clojure functions are full of let expressions. In fact, let is one of the most commonly used Clojure features, up there with defn and def. If, for example, you look at the Ring source code you will find the parse-params function. Here’s a slightly simplified version of it:
| | (defn parse-params [params encoding] |
| | (let [params (codec/form-decode params encoding)] |
| | (if (map? params) params {}))) |
Without diving into the belts and pulleys of Ring, we can deduce that parse-params decodes some raw parameter data into a value that is either a map or something else, presumably nil. Once it has the result of that decoding bound to params—courtesy of let—it proceeds to return the decoded value if it is indeed a map, or an empty ...
Read now
Unlock full access