groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: .with() variant that returns the original object
Date Tue, 15 Nov 2016 08:17:49 GMT
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 <paulk@asert.com.au> wrote:
> On Thu, Nov 10, 2016 at 6:45 AM, Jordan Martinez
> <jordanalexmartinez@gmail.com> 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.

Mime
View raw message