-
Notifications
You must be signed in to change notification settings - Fork 101
Closed
Labels
recipeRecipe requestedRecipe requested
Description
- Following on from Convert assigning Switch statements to Switch expressions #795
Describe the situation before applying the recipe
class A {
void doFormat(String str) {
String formatted = switch (str) {
case "foo": yield "Foo";
case "bar": yield "Bar";
case null, default: yield "unknown";
};
}
}
Describe the situation after applying the recipe
class A {
void doFormat(String str) {
String formatted = switch (str) {
case "foo" -> "Foo";
case "bar" -> "Bar";
case null, default -> "Other";
};
}
}
Have you considered any alternatives or workarounds?
Did not want to make this part of other recipes: it can stand alone for smaller complexity and isolated value.
Any additional context
Ideally we start this off minimally: only where all cases directly contain yield
. That way we have something quickly and can chain in this recipe visitor as a doAfterVisit
for SwitchCaseAssignmentsToSwitchExpression
.
Metadata
Metadata
Assignees
Labels
recipeRecipe requestedRecipe requested
Type
Projects
Status
Done