如果您替换代码,您所拥有的代码将按说明工作。
if-let
对于
let
. 所有条件逻辑都存在于
cond->
.
(def initial-number 0)
(let [a true b true] (cond-> initial-number a inc b (#(+ 5 %)))) => 6
(let [a false b true] (cond-> initial-number a inc b (#(+ 5 %)))) => 5
(let [a true b false] (cond-> initial-number a inc b (#(+ 5 %)))) => 1
(let [a false b false] (cond-> initial-number a inc b (#(+ 5 %)))) => 0