Daniel Holle
6ccf2a3df6
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 5m1s
17 lines
316 B
Java
17 lines
316 B
Java
import java.lang.Integer;
|
|
import java.lang.Double;
|
|
import java.lang.Number;
|
|
|
|
public record R(Number n) {}
|
|
|
|
public class SwitchOverload {
|
|
|
|
Number f(Double d) { return d * 2; }
|
|
Number f(Integer i) { return i * 5; }
|
|
|
|
public m(r) {
|
|
return switch(r) {
|
|
case R(o) -> f(o);
|
|
};
|
|
}
|
|
} |