User Tools

Site Tools


java:java12:enhanced-switch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:java12:enhanced-switch [2023/11/29 13:04] – created odeftajava:java12:enhanced-switch [2023/11/29 13:07] (current) odefta
Line 49: Line 49:
 } }
 </code> </code>
 +
 +<note>
 +  - In the enhanced version, the switch is used as an expression, which means it can directly return a value. 
 +  - Using the -> syntax eliminates the need for the break keyword, as each case is treated as a singular expression, and there's no "fall-through" to the next case. 
 +  - In the cases for Saturday and Sunday, we've combined the two cases into one for efficiency and clarity, demonstrating another improvement brought by the modern switch.
 +</note>
java/java12/enhanced-switch.1701255864.txt.gz · Last modified: 2023/11/29 13:04 by odefta