I agree, assuming that tap is not overloaded in any other popular use or 
language, it is not likely we would want to define tap in another way. Then we 
can appease both viewpoints. The other very important reason for with(boolean, 
Closure) and tap is that unfortunately .with(boolean, Closure) will always 
trigger warning about not returning from IDE, while tap can declare 
Closure<Void> I think which hopefully can trigger IDE to say no return is 
needed?

Jason

From: Søren Berg Glasius (GR8Conf EU) [mailto:[email protected]]
Sent: Tuesday, November 15, 2016 3:51 AM
To: [email protected]
Subject: Re: .with() variant that returns the original object

+1

I like that you provide both .with(true, Closure) and .tap(Closure)

Best regards,
Søren Berg Glasius
GR8Conf Europe organizing team

GR8Conf ApS
Mobile: +45 40 44 91 88, Web: www.gr8conf.eu<http://www.gr8conf.eu/>, Skype: 
sbglasius
Company Address: Buchwaldsgade 50, 5000 Odense C, Denmark
Personal Address: Hedevej 1, Gl. Rye, 8680 Ry, Denmark
--- GR8Conf - Dedicated to the Groovy Ecosystem

From: Guillaume Laforge <[email protected]><mailto:[email protected]>
Reply: [email protected]<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Date: 15. november 2016 at 09.24.36
To: [email protected]<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>, Paul King 
<[email protected]><mailto:[email protected]>
Subject:  Re: .with() variant that returns the original object


Sounds good to me!

On Tue, Nov 15, 2016 at 9:17 AM, Paul King 
<[email protected]<mailto:[email protected]>> wrote:
Ok, disussion seems to have finished on this topic. I was planning to
merge Christoph's PR with minor tweaks as needed. I was going to use
'tap' as the name.

At this stage, unless I hear violent objections, I was also planning
to provide the additional variant that was discussed:

with(boolean returning, Closure closure)

so folks could use with(true) if they wanted. It's a little clunky but
is the kind of thing we do in other places within Groovy, provides an
alternative for anyone that finds 'tap' totally foreign and might also
help steer users between the two related methods.

Cheers, Paul.


On Thu, Nov 10, 2016 at 3:04 PM, Paul King 
<[email protected]<mailto:[email protected]>> wrote:
> On Thu, Nov 10, 2016 at 6:45 AM, Jordan Martinez
> <[email protected]<mailto:[email protected]>> wrote:
>> What about `object.itselfWith(Closure)`? Then its understood as returning
>> the object itself but with the changes that follow.
>
> Both variants use 'itself' but only one returns 'itself', so I would
> regard that prefix as not distinguishing enough. You'd need something
> like 'withThen' or 'withReturning' to help distinguish between the
> two. The problem with 'withReturning' is that it is longer
> (character-wise) than 'with(true)' or just adding 'return it' or 'it'
> to the end of the closure - not that numbers of characters alone
> should be the most important metric.
>
> Cheers, Paul.



--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge<http://twitter.com/glaforge> / 
Google+<https://plus.google.com/u/0/114130972232398734985/posts>

This email message and any attachments are for the sole use of the intended 
recipient(s). Any unauthorized review, use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please contact the sender by 
reply email and destroy all copies of the original message and any attachments.

Reply via email to