Feedback on pattern matching (preview feature)

Brian Goetz brian.goetz at oracle.com
Sat Sep 25 15:28:11 UTC 2021


The example you cite is a peek into a feature not yet implemented (its a 
"and beyond" talk), so not only is there no "as patterns", but no 
patterns yet for which "as patterns" would be sensible.

When we have deconstruction patterns as per the example, you'll be able 
to provide an optional binding:

     case Point(var x, var y): // don't care about the point

     case Point(var x, var y) p: // bind the point too

which we believe will cover the need in a less "nailed on the side" way.

On 9/25/2021 10:21 AM, Vikram Bakshi wrote:
> Hello,
>
> I was playing around with the new pattern matching and wondered about the
> current absence of "as-patterns". Are there any plans to bring them to Java
> in a future JEP?
>
> An example use case where they could be useful is demonstrated in the
> recent video from the official Java YouTube channel (
> https://youtu.be/UlFFKkq6fyU) at 17:22.
>
>
> Regards,
> Vikram



More information about the amber-dev mailing list