3 ms·
Great! Java is getting destructuring. static void printUpperLeftColoredPoint(Rectangle r) { if (r instanceof Rectangle(ColoredPoint ul, ColoredPoin
by naruhodo 4y ago
Great! Java is getting destructuring.
static void printUpperLeftColoredPoint(Rectangle r) {
if (r instanceof Rectangle(ColoredPoint ul, ColoredPoint lr)) {
System.out.println(ul.c());
}
}
But lr is not used in this example. Where is the syntax for ignoring a component? Can we drop lr, or use a placeholder like '_' multiple times?
- kaba0 4y ago_ is reserved likely for this use case in advance, but AFAIK it is not yet settled on how exactly should it work. But as always, the language team does an excellent job on improvements which is exceedingly hard while you have to balance backward compatibility.