Skip to content

Commit 7e34e3c

Browse files
author
Bozhidar Batsov
committed
fixed bbatsov#9 - consistently place good examples before bad ones
1 parent 9378098 commit 7e34e3c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -182,62 +182,62 @@ You can generate a PDF or an HTML copy of this guide using
182182
* Use `when` instead of `(if ... (do ...)`.
183183

184184
```Clojure
185+
;; good
186+
(when pred
187+
(foo)
188+
(bar))
189+
185190
;; bad
186191
(if pred
187192
(do
188193
(foo)
189194
(bar)))
190-
191-
;; good
192-
(when pred
193-
(foo)
194-
(bar))
195195
```
196196

197197
* Use `if-not` instead of `(if (not ...) ...)`.
198198

199199
```Clojure
200-
;; bad
201-
(if (not pred)
202-
(foo))
203-
204200
;; good
205201
(if-not (pred)
206202
(foo))
203+
204+
;; bad
205+
(if (not pred)
206+
(foo))
207207
```
208208

209209
* Use `when-not` instead of `(when (not ...) ...)`.
210210

211211
```Clojure
212-
;; bad
213-
(when (not pred)
214-
(foo)
215-
(bar))
216-
217212
;; good
218213
(when-not pred
219214
(foo)
220215
(bar))
216+
217+
;; bad
218+
(when (not pred)
219+
(foo)
220+
(bar))
221221
```
222222

223223
* Don't wrap functions in anonymous functions when you don't need to.
224224

225225
```Clojure
226-
;; bad
227-
(filter #(even? %) (range 1 10))
228-
229226
;; good
230227
(filter even? (range 1 10))
228+
229+
;; bad
230+
(filter #(even? %) (range 1 10))
231231
```
232232

233233
* Favor the use of `complement` versus the use of an anonymous function.
234234

235235
```Clojure
236-
;; bad
237-
(filter #(not (some-pred? %)) coll)
238-
239236
;; good
240237
(filter (complement some-pred?) coll)
238+
239+
;; bad
240+
(filter #(not (some-pred? %)) coll)
241241
```
242242

243243
This rule should obviously be ignored if the complementing predicate
@@ -256,11 +256,11 @@ You can generate a PDF or an HTML copy of this guide using
256256
* Leverage `partial` when it would yield simpler code.
257257

258258
```Clojure
259-
;; good
260-
(map (partial + 5) (range 1 10))
261-
262259
;; good
263260
(map #(+ 5 %) (range 1 10))
261+
262+
;; (arguably) better
263+
(map (partial + 5) (range 1 10))
264264
```
265265

266266
## Naming

0 commit comments

Comments
 (0)