May 2018
Beginner to intermediate
290 pages
6h 43m
English
Clojure includes an if expression, and the good news is that there isn’t a lot to say about it: Clojure’s if is about as boring a programming-language feature as you are likely to come across. An if expression starts with the word if, which is followed by two other expressions: first a condition, then an expression to evaluate if the condition is true. The whole if expression is wrapped in round parentheses:
| | (defn print-greeting [preferred-customer] |
| | (if preferred-customer |
| | (println "Welcome back to Blotts Books!"))) |
Call the function in that example with true, and you will get a warm greeting printed. Call it with false, and you will get silence. You can also add an optional third expression inside ...
Read now
Unlock full access