Comments are useful texts to describe lines of code and improve the readability of a code.
It is ignored by the compiler and only for developers
Multiple ways we can write a comment in Clojure.
Clojure Comment Macro
Syntax
(comment & body)
Here is an example
(comment
;; First program.
;; Hello World.
(defn -main []
"I can say 'Hello World'."
(println "Hello, World!"))
)
Clojure Single line comments
It provides a semicolon(;
) macro that starts with a single line, followed by text. text is ignored by the compiler.
Single-line comments can be new line or inline comments.
; Single line comments
(+ 12 1)
Inline comments
(+ 12 1) ; inline comments
with this, You can add multiple ;
to identify heading types.
;
- used for inline or single-line comments
;;
- Documentation comments for functions that contain strings
;;;
- Documentation comments for a group of functions declared in a single file
;;;;
- File level comments, higher level in a file
Multi-line comments
Multi-line comments allow to add of comments to multiple lines of code.
Comments can be placed in multiple lines nested in ()
or []
.
Syntax