java:java12:enhanced-switch
Differences
This shows you the differences between two versions of the page.
java:java12:enhanced-switch [2023/11/29 13:04] – created odefta | java:java12:enhanced-switch [2023/11/29 13:07] (current) – odefta | ||
---|---|---|---|
Line 49: | Line 49: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | < | ||
+ | - 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' | ||
+ | - 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. | ||
+ | </ |
java/java12/enhanced-switch.1701255864.txt.gz · Last modified: 2023/11/29 13:04 by odefta