Two Scala annotations

bearophile bearophileHUGS at lycos.com
Mon Jul 2 07:37:53 PDT 2012


Don Clugston:

> Do you have a reference for this Java behaviour? I did a quick 
> google, and everything I found indicates that case labels must 
> be constants.

Thank you for your answer, Don.

I have compiled this Java code:

class Main {
     public static void main(String[] args) {
         int x = 2;
         int y = 2;
         switch(x) {
             case 1: break;
             case y: break;
         }
     }
}


It gives:

Main.java:7: error: constant expression required
             case y: break;
                  ^
1 error

As you see:
http://ideone.com/wAXMZ

Bye,
bearophile


More information about the Digitalmars-d mailing list