Mixing record patterns and literal/enum patterns?
Remi Forax
forax at univ-mlv.fr
Tue Sep 27 05:55:20 UTC 2022
> From: "Tesla Ice Zhang" <ice1000kotlin at foxmail.com>
> To: "amber-dev" <amber-dev at openjdk.org>
> Sent: Tuesday, September 27, 2022 1:18:24 AM
> Subject: Mixing record patterns and literal/enum patterns?
> Hi,
> Is it currently possible/planned to have mixed literal or enum patterns? E.g.,
> enum E { a, b }
> record R(E e) {}
> And use the pattern
> case R(E.a) something something
It's what we call a constant pattern. The syntax is still in flux.
Given that a switch on an enum does not require the class of the enum constant to be specified, another possible syntax may be case R(a),
or we may want a quoting mechanism for the constants, case R('E.a) or case R(== E.a).
Anyway, you can already write case R(E e) when e == E.a.
> Regards,
> Tesla
regards,
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20220927/d29642fe/attachment-0001.htm>
More information about the amber-dev
mailing list