Created
March 23, 2021 14:43
-
-
Save bufferings/1ef0adf394461a09eb72ae6ff02b634e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int switchSample1(DayOfWeek dayOfWeek) { | |
return switch (dayOfWeek) { | |
case MONDAY, TUESDAY: | |
yield 1; | |
case WEDNESDAY, THURSDAY, FRIDAY: | |
yield 2; | |
case SATURDAY: | |
yield 3; | |
case SUNDAY: | |
yield 4; | |
}; | |
} | |
int switchSample2(DayOfWeek dayOfWeek) { | |
return switch (dayOfWeek) { | |
case MONDAY, TUESDAY -> 1; | |
case WEDNESDAY, THURSDAY, FRIDAY -> 2; | |
case SATURDAY -> { | |
System.out.println("Hello"); | |
yield 3; | |
} | |
case SUNDAY -> 4; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment