fred icon indicating copy to clipboard operation
fred copied to clipboard

Replace Java 1.4 era 'for' loops

Open Juiceman opened this issue 1 year ago • 9 comments

Use Enhanced 'for' loops

Juiceman avatar Mar 18 '24 01:03 Juiceman

While the enhanced for loops are nice, I would suggest to actually go one step further and use the Stream API, e.g.

buckets.stream().forEach(Bucket::free);

Of course that’s only possible in places where the method being called does not throw exceptions…

Bombe avatar Mar 18 '24 11:03 Bombe

If you're following Bombe's suggestion, please consider leaving out the .stream() (just using Iterable's forEach(Consumer)):

buckets.forEach(Bucket::free);

bertm avatar Mar 18 '24 22:03 bertm

@Bombe could you review this one ?

hernic avatar May 06 '24 11:05 hernic