9 ms·
Difference with pipe operator would be 1. can't be extended. myhashmap.entrySet() .stream() .flattenBars() .toFoo() 2. (As a result
by kilotaras 5y ago
Difference with pipe operator would be
1. can't be extended.
myhashmap.entrySet()
.stream()
.flattenBars()
.toFoo()
2. (As a result of 1) - applies only to streams
- qsort 5y ago> can't be extended They can be extended arbitrarily by defining collectors. The Stream interface is very well designed. For example your "toFoo" would be .collect(Collector(<foo-provider>, <foo-accept>, <foo-merge>, <foo-finisher>)). All of them can be arbitrary functions working on arbitrary types. That's the standard library implementation of "toList", in fact! > applies only to streams You're exactly correct here, but for legacy reasons Java did not have a choice. I'm the first to admit mylist.stream().map(f).toList() is dumb. A list is a functor, dammit! It's the best possible solution given the existing constraints, but it's definitely limited in what it can do.