Exception handling in switch (Preview)

Pablo Grisafi pablogrisafi1975 at gmail.com
Mon Apr 22 14:55:24 UTC 2024


Dear experts
Tagir Valeev does not like the proposal and among other things suggests

>
> But we are still limited by a single expression in the selector. An alternative would be
> Integer toIntOrNull(String s) {
>  return try { yield Integer.parseInt(s); }
>    catch(NumberFormatException _) { yield null; };
> }

Por que no los dos?
I do like the proposal, but also like the yield-in-try option Tagir
Valeev proposes
In fact, why can't we have yield in any block? That will give as
if-expressions, try-expressions and even simply block-expressions
int a = {
  var x  = ....
  var y  = ....
  yield x + y;
}

thanks for your time

Pablo Grisafi
pablogrisafi1975 at gmail.com


More information about the amber-spec-observers mailing list