Improve switch expression for lambda

Tesla Zhang ice1000kotlin at foxmail.com
Tue Aug 9 23:44:37 UTC 2022


Hi!


I wanted to write the following one-line lambda


Consumer<X> f = x -> switch (x) {
  case L1 -> System.out.println("!");
}


Provided L1 the only instance of enum X. 


The above lambda has to be rewritten as a block-lambda because my switch returns void. Can we allow this case?



Regards,
Tesla
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20220809/b29c49c3/attachment.htm>


More information about the amber-dev mailing list