Comments

There are several ways to create comments in Clojure. The most common is to use ;, which creates a comment to the end of the line. While everything after the first ; is ignored, you’ll often see multiple semicolons to make a greater visual impact:

 ;; this is a comment

Clojure also contains a comment macro that ignores its body and returns nil. This is useful to wrap around a block of existing code. However, because it’s still read by the Clojure reader, it must be valid code.

 (comment
  (​defn​ ignore-me []
 ;; not done yet
  ))

One common use of the comment macro is to save a chunk of utility or test code in a comment block at the end of the file, which is useful in combination with REPL-based development.

Clojure also contains ...

Get Programming Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.