4 ms·
Consider the following scenario: You have a Toilet object with a method flush. var toilet = house.getToilet(); toilet.flush(); Now you find out that upda
by blauditore 10y ago
Consider the following scenario:
You have a Toilet object with a method flush.
var toilet = house.getToilet();
toilet.flush();
Now you find out that updating Toilet objects is somehow expensive and decide to wrap it into a Cache<Toilet>. Unfortunately, Cache also has a flush method, so there will be no compile time error, but functionality is broken now.
I agree this problem would also occur when using chained calls (house.getToiled().flush()), but explicit types could cover at least some of the cases.
- naasking 10y ago> Now you find out that updating Toilet objects is somehow expensive and decide to wrap it into a Cache<Toilet>. Unfortunately, Cache also has a flush method, so there will be no compile time error, but functionality is broken now. This has happened to me exactly 0 times since type inference was introduced in 2007/2008.