We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I was wondering how often you guys use lambda expressions? I really love them, it allows me to write quick short really flexible code.
Instead of a 100% solution class I often go with a 80% solution and do the remaining 20% with lambda expressions.
It really sucks processing IDE can't deal with them. I think lambda's could have made processing a lot better.
Comments
We don't even have
enum
or even a 100% Java 5 compliant IDE! ~X(To give an example, I work on a GUI. Now I can code what a toggle should do instead of relying on reflection.
can you post us a link to a wikipedia or other ressource pls?
https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
Thanks!
Np!
I just tested, enums
and lambda'sfinally work!Enum compatibility arrived along P3. But lambda didn't.
I'm still using Processing version 3.1.2. And it doesn't recognize the
->
operator! :(At least JS got lambdas via the
=>
operator: \m/https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
Would have been nice for GSOC
or GSOC 2017...
I've used lambdas but to be 100% honest it's mostly because IntelliJ told me so. This was using Processing as an external library.
Is this a functionality issue or a style issue? Is there anything that you need lambdas for that you cannot do already with anonymous functions, or is it just that the functional style makes the code seem concise / elegant?
I don't think it ever can be a functional issue cause what is possible with a lambda is in some way possible without.
As for elegance, take this:
button(20, 20, "saveframe").click(() -> saveFrame());
vs:
The last example requires so much code that I totally change my design to keep away from using interfaces.
Also lambdas are not just about cleaner, shorter code - they offer better performance than anonymous classes too!
I'm supporting lambdas a lot now in the non-Processing specific bits of Praxis LIVE. Streams, etc. are also great!