Skip to content

Commit d3133bb

Browse files
committed
Add a rule about the indentation of multi-arity functions
1 parent c997f08 commit d3133bb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ You can generate a PDF or an HTML copy of this guide using
137137
(defn foo
138138
([x] (bar x))
139139
([x y]
140-
(if (predicate? x)
141-
(bar x)
142-
(baz x))))
140+
(if (predicate? x)
141+
(bar x)
142+
(baz x))))
143143

144144
;; bad
145145
(defn foo
@@ -148,6 +148,28 @@ You can generate a PDF or an HTML copy of this guide using
148148
(baz x)))
149149
```
150150

151+
* <a name="multiple-arity-indentation"></a>
152+
Indent each arity form of a function definition vertically aligned with its
153+
parameters.<sup>[[link](#multiple-arity-indentation)]</sup>
154+
155+
```Clojure
156+
;; good
157+
(defn foo
158+
"I have two arities."
159+
([x]
160+
(foo x 1))
161+
([x y]
162+
(+ x y)))
163+
164+
;; bad - extra indentation
165+
(defn foo
166+
"I have two arities."
167+
([x]
168+
(foo x 1))
169+
([x y]
170+
(+ x y)))
171+
```
172+
151173
* <a name="align-docstring-lines"></a>
152174
Indent each line of multi-line docstrings.
153175
<sup>[[link](#align-docstring-lines)]</sup>

0 commit comments

Comments
 (0)