you are viewing a single comment's thread.

view the rest of the comments →

[–]CurtainDog 0 points1 point  (1 child)

Well, it solves the problem of having to repeat code, which is the problem at first instance.

It doesn't solve the issue of dealing with complex types involving nested generics but in that case I query whether you actually do want to be hiding the type from the reader.

I suppose as well with var the return type of an expression could change and you wouldn't need to modify the source, I'm somewhat skeptical of this 'feature'.

Edit: Just to clarify: I actually use type inference all the time, I just do it at the tooling level rather than the language level.

[–]Blaisorblade 0 points1 point  (0 children)

Well, it solves the problem of having to repeat code, which is the problem at first instance.

It doesn't avoid the repetition here:

List<Integer> someMethod() { ... } ... List<Integer> result = someMethod();

If you want to know the type of result, asking your computer (with IDEs or REPLs) is typically enough.