Usually when using Java streams, I’m mid-thought and the IDE cannot offer suggestions on my not-yet-syntactically-valid code. I end up typing the whole Collectors part by sheer muscle memory. I think this makes sense.
Little know fact, you can specify the type in a stream variable declaration. This helps the IDE (and the next guy) figure out what you're trying to do:
It’s type safe once you have it all written out and syntactically valid. Just like you can omit types when working with generics using diamond operator. However, this is a nice reminder that lambda argument types can help sometimes.
5 comments
[ 5.0 ms ] story [ 19.2 ms ] threadorders.stream().filter((Order filterCandidate) -> filterCandidate.getTotal() > 2000).collect(toList());
Kinda makes me wonder what else I'm missing though.