JEP 286: Local-Variable Type Inference
openjdk.java.net
JEP 286: Local-Variable Type Inference
1–10 of 132 posts
Re: JEP 286: Local-Variable Type Inference
#2Re: JEP 286: Local-Variable Type Inference
#3The website isn't the prettiest but Lombok is a fantastic addition to a Java codebase and massively reduces the amount of boiler plate often associated with Java. A list of Lombok features https://projectlombok.org/features/index.html
Java 8 + Lombok + Guava == happy developers (well at least in my case :) ).
Re: JEP 286: Local-Variable Type Inference
#4Re: JEP 286: Local-Variable Type Inference
#5Re: JEP 286: Local-Variable Type Inference
#6 var list = new ArrayList();
There is no way to infer the type of the generic parameter. So we will go back to doing: var list = new ArrayList();
Which isn't a big deal IMO because the generic parameters had to be specified on the LHS anyway to use the diamond. You also end up using fewer characters in general with var even without being able to use the diamond.Regarding val vs let, I prefer let simply because it's harder to accidentally type let vs typing var instead of val (or vice versa).
Re: JEP 286: Local-Variable Type Inference
#7I wish most of the xtend enhancements were integrated to java asap!
Re: JEP 286: Local-Variable Type Inference
#8Re: JEP 286: Local-Variable Type Inference
#9This is pretty nice. Hope it goes through. It's about time that we had local-variable inference in Java. It does mean that the diamond can't be used this way: var list = new ArrayList (); There is no way to infer the type of the generic parameter. So we will go back to doing: var list = new ArrayList (); Which isn't a big deal IMO because the generic parameters had to be specified on the LHS anyway to use the diamond…
Re: JEP 286: Local-Variable Type Inference
#10This is pretty nice. Hope it goes through. It's about time that we had local-variable inference in Java. It does mean that the diamond can't be used this way: var list = new ArrayList (); There is no way to infer the type of the generic parameter. So we will go back to doing: var list = new ArrayList (); Which isn't a big deal IMO because the generic parameters had to be specified on the LHS anyway to use the diamond…
I like the approach mentioned of just reusing final for immutability.