2 ms·
How is composition inconvenient?
by yxhuvud 2y ago
How is composition inconvenient?
- mdaniel 2y agoContrast the Java way class Delegated implements Base { final Base b; public Delegated(Base b) { this.b = b; } @Override public void printMessage() { b.printMessage(x); } @Override public void printMessageLine() { b.printMessageLine(x); } with the Kotlin way https://kotlinlang.org/docs/delegation.html#overriding-a-member-of-an-interface-implemented-by-delegation https://kotlinlang.org/docs/delegation.html#overriding-a-mem... OT1H, yes, sane people using IJ would just alt-Insert, choose delegate to, and move on with life. But those misguided folks using VS Code, vim, or a magnetized needle and a steady hand would for sure find delegating to a broader interface to be a huge PITA