Class SwitchYieldPreviewExamples
java.lang.Object
net.jrodolfo.java_evolution.java13.SwitchYieldPreviewExamples
Demonstrates
yield in switch expressions as a Java 13 preview
refinement.
Java 12 previewed switch expressions, but block branches still needed a clear way to produce a value when they contained multiple statements.
Java 13 adjusted the preview by adding yield. It solves the
readability problem by making the branch result explicit.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SwitchYieldPreviewExamples
public SwitchYieldPreviewExamples()
-
-
Method Details
-
grade
Usesyieldwhen a switch branch needs multiple statements.- Parameters:
score- a numeric score- Returns:
- a grade label
-