Closed hamoid closed 5 years ago
Hey there!
This fork moved us from a Java 5 to a Java 8 grammar which is why generics and lambdas work now. I think var was added in Java 10. So, it’s expected that the above snippet wont work but it doesn’t mean it’s desired.
Originally I was going to tackle moving to an 11 grammar in a separate PR as there’s some particularly meddlesome changes involved but ... we might still have some time on our hands ... so I’ll take a look again at moving the grammar to Java 11. Thanks!
Hey @hamoid! Thank you again for the bug report. The more I thought about it the more I realized that missing some of the new Java 11 features might be asking for some serious confusion (in particular, missing var
is a bummer as more documentation online begins to adopt it). I have a working draft of this. I'll post shortly.
import java.util.*;
import java.util.function.*;
void setup() {
List<String> list = new ArrayList<>();
list.add("line1\nline2");
list.add("line3");
// Local variable type inference in loop
for (var s : list) {
println(s);
}
// Thanks https://codete.com/blog/java-8-java-11-quick-guide/
IntFunction<Integer> testLambda = (var x) -> x * 2; // Type inference in lambda
// Local variable type inference
var testString = list.get(0);
println(testString.lines().count()); // Java 11 API
}
Amazing! Thank you for doing this :)
The merge is in!
Hi :) Is this expected?