JEP325: Switch expressions spec

Kevin Bourrillion kevinb at
Mon Apr 23 18:02:30 UTC 2018

On Fri, Apr 20, 2018 at 11:55 AM, Guy Steele <guy.steele at> wrote:

You know, if s2 is short (say, less than 30 or 40 characters), there are
> worse things than writing
>          case A -> s1;
>          case null -> s2;
>          default   -> s2;
> especially if you use spaces (as I just did) to line up the two
> occurrences of s2 to make it easy to see they are identical.
> And if s2 is long, there are worse things than making a little sub method
> to handle it:
>          case A -> s1;
>          case null -> frobboz(a, b);
>          default   -> frobboz(a, b);
>     int frobboz(int a, String b) { … }
> And if even THAT is not satisfactory, well, there are worse things than
> giving up on the arrows and just using colons (and break, if needed).

I think neither of these goes down well. Having to repeat yourself at all,
while normal cases get to use comma, will feel very wrong. Having to
abandon arrowform over this would be even worse.

BUT, on the other hand, if we wanted to: instead of, or in addition to,
>         case pat1, pat2, pat3 -> s;
> we could allow the form
>         case pat1 -> case pat2 -> case pat3 -> s;

This seems like a step backward to me (whether it is instead or in

fwiw, I think `default, case null ->` is superior to all of these options.

Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the amber-spec-experts mailing list