Two Scala annotations

Walter Bright newshound2 at digitalmars.com
Mon Jul 2 11:52:49 PDT 2012


On 7/2/2012 7:37 AM, bearophile wrote:
> 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

Put "final" in front of y, and it will compile. Remember, this was done for D1 
that didn't have const.




More information about the Digitalmars-d mailing list