On Tue, Mar 2, 2021 at 5:05 AM Brian Goetz <[email protected]> wrote:
> as *either* a local variable declaration, *or* a pattern match, without the
> user being able to tell the difference:
>
> - The scoping is the same (since the pattern either completes normally or
> throws);
> - The mutability is the same (we fixed this one just in time);
> - The set of conversions, applicable types, and potential exceptions are the
> same (exercise left to the reader.)
A couple of other things to consider:
1. C-style array declaration is not allowed in patterns.
2. For local variable declaration, the initializer can omit `new int[]` part:
int data[] = {1, 2, 3}
3. Local variable type may affect the initializer type (e.g.
List<String> list = List.of()). What about patterns? Can we say that a
`List<String> list` pattern is a total pattern over `List.of()`
expression type?
With best regards,
Tagir Valeev