> On Apr 19, 2018, at 6:27 PM, Brian Goetz <brian.go...@oracle.com> wrote:
> 
> 
>> 
>> Can a single-statement case have a variable declaration as that statement, 
>> and what would be its scope?
> 
> No, a local variable declaration is a BlockStatement (JLS 14.2), not a 
> Statement (JLS 14.5).  So you could say:
> 
>     case FOO -> println(3);
> 
> or
> 
>     case FOO -> {
>         int x = 4;
>         println(x);
>     }
> 
> Of course, you don't have to ask about the scope of x.  

Please ignore my previous message; I stand corrected.  (I forgot about the 
distinction between Statement and a BlockStatement.  Time for me to go home and 
get some supper.)

—Guy


Reply via email to