1// Use the yield keyword to produce a result in a switch expression.
2
3int result = switch (month) {
4 case JANUARY, JUNE, JULY -> 3;
5 case FEBRUARY, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER -> 1;
6 case MARCH, MAY, APRIL, AUGUST -> {
7 int monthLength = month.toString().length();
8 yield monthLength * 4;
9 }
10 default -> 0;
11};