MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/49prnu/var_keyword_proposed_for_java/d0tvip0/?context=3
r/java • u/adila01 • Mar 09 '16
312 comments sorted by
View all comments
Show parent comments
26
I do understand that.
My point was that:
var foo = whatevs
is more difficult for humans to read while going through somebody else's code.
12 u/covercash2 Mar 09 '16 It seems safer than that in the article.More like:var foo = "string"; var foo = 1; var bar = 1.0; var biz = 1f;We all know what those will compile to. Anything else will have to be declared explicitly, though only once:var object = new ObjectClass();instead ofObjectClass object = new ObjectClass();Although, I agree with the sentiment that a superclass should be used in a lot of cases, and that fudges with this var syntax a bit. 86 u/ApostleO Mar 09 '16 The problem still arises when you find yourself staring at a line like...var foo = someObject.method();Let's say you are doing a code review, not in your IDE at the time. You now have to track down the return type of that method to know what 'foo' is. 37 u/evil_burrito Mar 09 '16 That's exactly my point. Thanks.
12
It seems safer than that in the article.
More like:
var foo = "string"; var foo = 1; var bar = 1.0; var biz = 1f;
We all know what those will compile to. Anything else will have to be declared explicitly, though only once:
var object = new ObjectClass();
instead of
ObjectClass object = new ObjectClass();
Although, I agree with the sentiment that a superclass should be used in a lot of cases, and that fudges with this var syntax a bit.
86 u/ApostleO Mar 09 '16 The problem still arises when you find yourself staring at a line like...var foo = someObject.method();Let's say you are doing a code review, not in your IDE at the time. You now have to track down the return type of that method to know what 'foo' is. 37 u/evil_burrito Mar 09 '16 That's exactly my point. Thanks.
86
The problem still arises when you find yourself staring at a line like...
var foo = someObject.method();
Let's say you are doing a code review, not in your IDE at the time. You now have to track down the return type of that method to know what 'foo' is.
37 u/evil_burrito Mar 09 '16 That's exactly my point. Thanks.
37
That's exactly my point. Thanks.
26
u/evil_burrito Mar 09 '16
I do understand that.
My point was that:
is more difficult for humans to read while going through somebody else's code.