Feature Request for Primitive Patterns (JEP 455)
Brian Goetz
brian.goetz at oracle.com
Tue Sep 26 00:08:38 UTC 2023
We considered this for byte (and short and int and long...), but having
written a lot of switches over byte, I am not sure I've encountered one
that enumerates all 255 cases.
If and when we have range patterns (n..m), I think the story might be
different.
On 9/25/2023 5:02 PM, David Alayachew wrote:
>
> Hello Amber Dev Team,
>
> I have a feature request to be included as part of JEP 455 --
> Primitive Patterns.
>
> > Since the boolean type (and its corresponding boxed type)
> > has only two distinct values, a switch that lists both
> > the true and false cases is considered exhaustive:
> >
> > boolean b = ...
> > switch (b) {
> > case true -> ...
> > case false -> ...
> > // Alternatively: case true, false -> ...
> > }
> >
> > It is a compile-time error for this switch to include a
> > default clause.
>
> I formally request that this functionality be extended to the
> primitive type byte.
>
> Thank you for your time and help!
> David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230925/b06d3378/attachment.htm>
More information about the amber-dev
mailing list