You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With #63, basic support for Java 14 switch expressions was added. There is a multi-statement form of switch expressions that is not yet supported, using the yield keyword to yield the expression from the block of statements.
We might be able to half-translate this into IIFE-style lambda functions, with a Func<SPECIFY_ME> type where the user must replace SPECIFY_ME with whatever the appropriate type is (which might not be obvious syntactically i.e. if you use var).
This is ugly but it might work in most cases. A warning should be emitted whenever we have to do this. Also note return from the lambda instead of yield.
For example:
Dayday=Day.WEDNESDAY;intnumLetters=dayswitch{MONDAY or FRIDAY or SUNDAY=>((Func<SPECIFY_ME>)(()=>{Console.WriteLine(6);return6;}))(),
...};
The text was updated successfully, but these errors were encountered:
Switch expressions are incomplete if you can't have multiple lines because you usually need multiple lines. Having blocked-bodied expression arms makes total sense.
With #63, basic support for Java 14 switch expressions was added. There is a multi-statement form of switch expressions that is not yet supported, using the
yield
keyword to yield the expression from the block of statements.See: https://docs.oracle.com/en/java/javase/14/language/switch-expressions.html#GUID-BA4F63E3-4823-43C6-A5F3-BAA4A2EF3ADC__GUID-4900EB1C-3832-4CB8-ACAE-A87675260B75
Example:
We might be able to half-translate this into IIFE-style lambda functions, with a
Func<SPECIFY_ME>
type where the user must replace SPECIFY_ME with whatever the appropriate type is (which might not be obvious syntactically i.e. if you usevar
).This is ugly but it might work in most cases. A warning should be emitted whenever we have to do this. Also note
return
from the lambda instead ofyield
.For example:
The text was updated successfully, but these errors were encountered: