Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure by
retagged by

Hi, thanks for all your time and effort; it's genuinely appreciated in an increasingly strange world.


user> (def ^:const x 1)
#'user/x
user> (case 1 x :x)
Execution error (IllegalArgumentException)
No matching clause: 1

I think I understand, from the docstring, why this doesn't do what I thought it might, but I am curious if it could or should. (:

1 Answer

0 votes
by

The doc string for case says: "The test-constants are not evaluated. They must be compile-time literals, and need not be quoted." In your example, the x is not evaluated, it's literally just the symbol x.

...