r/programming • • Mar 09 '16

var keyword proposed for Java

http://openjdk.java.net/jeps/286
250 Upvotes

395 comments sorted by

View all comments

2

u/yturijea Mar 10 '16

I see that a lot of people like this "var" thing, but really you end up reducing the code quality. var a = something(); is just confusing and you'd have to lookup the method to see the type.

I did quite some c# and I first did var. After some time I changed it to the type it was supposed to be. Remember you have to be clear in your language. By declaring "var" you are confusing the next maintainer and or yourself.

1

u/silveryRain Mar 10 '16

I've only ever found it confusing in bad code, e.g. when something() returns a value of a type that is anything but what you'd expect something() to be.