Share your thoughts in the 2021 Clojure Community Survey!

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

0 votes
in Clojure by
closed by

case seems to behave inconsistently for collections containing java.lang.Integers.
For example, take this function:

(defn test-case [v]
  (case v
    [1 -1] :one
    [1] :two
    :default))

Calling it with [1 -1] or [1] as an argument yields the expected result, and so does calling it with [(int 1)] (=> :one). However, with two elements, this does not work anymore:

(test-case [(int 1) (int -1)]) => :default

To me this seems like a bug, considering that (= [1 -1] [(int 1) (int -1)]) => true.

Is there anything I'm missing here?

This was tested on Clojure version 1.10.1.547.

Edit: only now saw the relevant issue. Sorry about that.

...