68
votes

Such as:

(println clojure-version)

?

4

4 Answers

93
votes

Even shorter :

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

Oops, I have to upgrade...

31
votes

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".

23
votes

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

*clojure-version*
=> {:major 1, :minor 3, :incremental 0, :qualifier nil}
1
votes

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}