News for hackers. Stuff that matters.
Re:JEP 443: Unnamed Patterns and Variables (Preview) by userbinator on Tuesday March 21, 2023 @10:10PM (#35255857)
This code uses an enhanced for loop to step through a collection, calculating total as a side effect without using the loop variable order.

That seems like a very contrived example. I don't work with Java regularly, but wouldn't that be better written as something like this?

    int total = max(orders.length, LIMIT);
Re:JEP 443: Unnamed Patterns and Variables (Preview) by kaba0 on Wednesday March 22, 2023 @03:22AM (#35257864)
It is a contrived example, but the idea/code pattern isn’t — I have written plenty of code where I had to iterate over a collection with a for loop, but didn’t use the exact element.

But obviously for typical usage one should probably just use the stream API.

Re:JEP 443: Unnamed Patterns and Variables (Preview) by frant-hartm on Wednesday March 22, 2023 @03:30AM (#35257911)
Orders may be Iterable, which doesn't have length/size().