File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1291,6 +1291,24 @@ Prefer `vec` over `into` when you need to convert a sequence into a vector.
1291
1291
(into [] some-seq)
1292
1292
----
1293
1293
1294
+ === Converting Something to Boolean
1295
+
1296
+ Use the `boolean` function if you need to convert something to an actual boolean value (`true` or `false`).
1297
+
1298
+ [source,clojure]
1299
+ ----
1300
+ ;; good
1301
+ (boolean (foo bar))
1302
+
1303
+ ;; bad
1304
+ (if (foo bar) true false)
1305
+ ----
1306
+
1307
+ NOTE: Don't forget that the only values in Clojure that are "falsey" are `false` and `nil`. Everything else
1308
+ will evaluate to `true` when passed to the `boolean` function.
1309
+
1310
+ You'll rarely need an actual boolean value in Clojure, but it's useful to know how to obtain one when you do.
1311
+
1294
1312
=== `when` vs `if` [[when-instead-of-single-branch-if]]
1295
1313
1296
1314
Use `when` instead of `(if ... (do ...))`.
You can’t perform that action at this time.
0 commit comments