Hacker News new | ask | show | jobs
by kuschku 3504 days ago
> How do you reverse a stream in java?

By calling .reverse() on it, and making it iterate the other way around?

> extension methods

Extension methods are something that’s really really problematic, and easy to create confusion with.

That said, I’d just import the functions I want to call on the stream into my local namespace with import static.

1 comments

When i last used the stream api i don't remember it had a reverse functionality. Still that was an example only.

Edit: Just checked: https://docs.oracle.com/javase/8/docs/api/java/util/stream/S... no reverse().

Fyi for 1 year I have been working on a Stream API heavy app. Now working on a C# project with quite some LINQ. I know both sides to some extent...