4 ms·
>Diamond operator Wow. So instead of adding something like var in C# or auto in C++ they went the opposite way. Makes no sense to me.
by Xdes 13y ago
>Diamond operator
Wow. So instead of adding something like var in C# or auto in C++ they went the opposite way. Makes no sense to me.
- twic 13y agoI suspect this was because it was a smaller change. Inferring from the type of the variable to the type of the expression only has the inferred type flowing inwards to smaller scope. Inferring from the expression to the variable gets inferred types spreading out over the whole program. That is possible, and is how many languages work, but it would have been a huge change for Java. For better or for worse, it's in the nature of Java to be conservative, and not make huge changes.
- eropple 13y agoThe diamond operator isn't variable type inference, it's parameter type inference for generics. It should have var/auto, for sure, but this is a different thing.
- deleted 13y ago[deleted]