Similar to
Describe the situation before applying the recipe
class B {
String doFormat(String str) {
switch (str) {
case "foo": return "Foo";
case "bar": return "Bar";
case null, default: return "Other";
}
}
}
Describe the situation after applying the recipe
class B {
String doFormat(String str) {
return switch (str) {
case "foo" -> "Foo";
case "bar" -> "Bar";
case null, default -> "Other";
};
}
}
Any additional context
Ideally again starting only with switches where every case is a direct return, and only later expanding to cover additional usages.