File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,27 @@ when there are no arguments on the same line as the function name.
165165 [x] (bar x))
166166 ```
167167
168+ * <a name =" docstring-after-fn-name " >
169+ When adding a docstring – especially to a function using the above form – take
170+ care to correctly place the docstring after the function name, not after the
171+ argument vector. The latter is not invalid syntax and won’t cause an error,
172+ but includes the string as a form in the function body without attaching it to
173+ the var as documentation.
174+ <sup >[[ link] ( #docstring-after-fn-name )] </sup >
175+
176+ ```Clojure
177+ ;; good
178+ (defn foo
179+ "docstring"
180+ [x]
181+ (bar x))
182+
183+ ;; bad
184+ (defn foo [x]
185+ "docstring"
186+ (bar x))
187+ ```
188+
168189* <a name =" oneline-short-fn " ></a >
169190 Optionally omit the new line between the argument vector and a short
170191 function body.
You can’t perform that action at this time.
0 commit comments