I’m learning Clojure and am messing around on the REPL. For assert, the documentation says
Usage: (assert x)
(assert x message)
Evaluates expr and throws an exception if it does not evaluate to
logical true.
So I expected (assert false "Error message") to raise an error and output "Error message". However, it gives
java.lang.IllegalArgumentException: Wrong number of args (4) passed to: core$assert (NO_SOURCE_FILE:0)
Why does it say I have four arguments, and what would be the correct usage? The documentation to assert is not too verbose.
I just tried it out on 1.2.1 and I get the same behavior as you.
Then I tried
(doc assert)on 1.2.1 in REPL as well:It seems that the message was added in 1.3 so you can only use the version with one parameter in 1.2.
If you are browsing online documentation be sure you are reading the correct version. Whenever in doubt type
(doc the-function-or-macro-name)in REPL and see the documentation right there. I usedocmuch more often than online docs – it’s always up to date with the version I’m using and it’s already right there under my fingers anyway.