2 ms·
Sure. Then, if you're set on using lambdas, I'd recommend this, to at least take away the ability to choose <T> from the caller. static Shape<?> Circle(int
by Twisol 6y ago
Sure. Then, if you're set on using lambdas, I'd recommend this, to at least take away the ability to choose <T> from the caller.
static Shape<?> Circle(int x, int y, int r) {
return (circle, rectangle) -> circle.apply(x, y, r);
}
static Shape<?> Rectangle(int x, int y, int w, int h) {
return (circle, rectangle) -> rectangle.apply(x, y, w, h);
}