Thanks for sharing this.
Anyone can use the Java10
var as they like, of course, but based on my limited exposure I’m not keen on incorporating use of var into Processing reference / examples for language learners.
My thinking: given that Java is still statically typed, it seems to me like using “var” is an advanced feature for people with a deep understanding of types – the coder still needs to understand that their var is actually an int or float or String and cannot be reassigned, but that is no longer explicit in their sketch. In particular, people switching back and forth between p5.js / Processing may be deeply confused by var in Processing(Java) examples, because it is the “same” keyword but with very different usage rules. The primary point of contact will be people pasting p5.js sketches into Processing PDE (Java mode) and trying to edit them until they work–and that might go okay, but the new errors may be much more confusing than the old ones were that simply rejected the keyword.
I did see one use of
var that made potential sense to me for learners: to shorten very long object declarations, making them more readable and less redundant / intimidating.
ArrayList<PVector> points = new ArrayList<PVector>();
var points = new ArrayList<PVector>();
For advanced users, that answer also mentions var for anonymous types as an alternative to lambdas.