68

Such as:

(println clojure-version)

?

Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
qrest
  • 711
  • 1
  • 5
  • 3

5 Answers5

94

Even shorter :

user> (clojure-version)
"1.2.0-beta1"
user> 

Oops, I have to upgrade...

Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
31

Very close.

user> (println *clojure-version*)
{:major 1, :minor 2, :incremental 0, :qualifier }
nil

Most builtin "global" variables like this have Common Lisp-style asterisk "earmuffs".

Brian Carper
  • 71,150
  • 28
  • 166
  • 168
  • 2
    You can also just type *clojure-version* and the REPL will print the toString value. Fancy, that! – Isaac Aug 24 '10 at 22:51
23

Just typing *clojure-version* will do the trick.

*clojure-version*
=> {:major 1, :minor 3, :incremental 0, :qualifier nil}
mikera
  • 105,238
  • 25
  • 256
  • 415
1

Extra repl examples

user=> (clojure-version)
"1.10.1"

user=> (println (clojure-version))
1.10.1
nil

user=> (print (clojure-version))
1.10.1nil

Use from clj

$ clj -M -e "(clojure-version)"
"1.10.1"

$ clj -M -e "(print (clojure-version))"
1.10.1

$ clj -M -e "*clojure-version*"
{:major 1, :minor 10, :incremental 1, :qualifier nil}
pbsladek
  • 616
  • 7
  • 12
1

clojure -M -e '(println "Java" (System/getProperty "java.version") "Clojure" (clojure-version))'

Nancy Jain
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 28 '22 at 17:15