java:java12:enhanced-switch
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| java:java12:enhanced-switch [2023/11/29 11:04] – created odefta | java:java12:enhanced-switch [2025/01/02 18:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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: (external edit)
