3 ms·
> However we still don’t have something like auto/let from cpp/rust. But things like auto are more verbose semantics, not less! And isn’t var in Java like aut
by chrisseaton 4y ago
> However we still don’t have something like auto/let from cpp/rust.
But things like auto are more verbose semantics, not less!
And isn’t var in Java like auto in C++?
- kaba0 4y agoThere is type inference for local variables indeed with var in java for a few versions now (from the top of my head it is available since 14?)
- mypalmike 4y agoYes. And you could use Lombok to do the same before that. (Though I'm one of the weirdos who likes Java in it's explicitness, which is related directly to its verbosity. I like reading code where I can see what the local variable types are.)
- kaba0 4y ago(I believe it depends on the exact scenario. In cases where the return type is not obvious I also much prefer explicit types (eg. ConcrType a = someObj.someMethod() ), but I don’t find A a = new A() any more readable than the var version)
- mypalmike 4y agoAgreed. I'm not sure that the shortcut existing in the language is worth the fact that other devs on my team will use it in the former case.