Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

confusing case behavior with a java static int

Tags:

clojure

I'm confused...this static value is equal to 5

user> java.awt.image.BufferedImage/TYPE_3BYTE_BGR
5

and a case statement should work like this

user> (case 5
        5 "yes"
        "huh?")
"yes"

but why does it work like this? Why doesn't it match?

user> (case java.awt.image.BufferedImage/TYPE_3BYTE_BGR
            java.awt.image.BufferedImage/TYPE_3BYTE_BGR "yes"
            "huh?")
"huh?"
like image 730
Roger Allen Avatar asked Mar 17 '13 00:03

Roger Allen


1 Answers

The test-constants in a case expression are not evaluated. So your statement is testing whether the number 5 is the same as the symbol java.awt.image.BufferedImage/TYPE_3BYTE_BGR. Since they aren't, it falls through to the default clause.

like image 193
Barmar Avatar answered Oct 14 '22 19:10

Barmar