Refactoring for DRY
Paul Sandoz
paul.sandoz at oracle.com
Tue Apr 9 02:02:22 PDT 2013
On Apr 9, 2013, at 5:18 AM, Barry Burd <bburd at drew.edu> wrote:
> Has tee() been implemented yet? I downloaded the binary a few days ago and I can't find tee().
>
It was renamed to peek, which i think would be marginally better than flatMap, plus such a consumer is also reusable in forEach. It's sailing a bit close to the wind in terms of non-interference.
However, i would write a Function to transform a Person into a Double and thereby being resuable in a map operation without updating state, but could be reused in a Consumer:
Function<Person, Double> f = p -> { ... };
Consumer<Person> c = p -> p.setPrice(f(p));
Paul.
>>>> On 4/8/2013 at 10:30 PM, in message <2CCAC7DA-F3DD-4EE3-9532-4CA54A446950 at gmail.com>, Sam Pullara <spullara at gmail.com> wrote:
> I think this would be most effectively done with tee()
>
>
More information about the lambda-dev
mailing list