From: tamouse mailing lists Date: 2013-04-22T21:15:51+09:00 Subject: Re: Tap method : good or bad practice ? --14dae9473a79720eb404daf20703 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Apr 21, 2013 5:21 PM, "Josh Cheek" wrote: > > On Sun, Apr 21, 2013 at 12:56 AM, S=C3=A9bastien Durand wrote: >> >> >> What is the Ruby way of doing this ? Is it common to use this >> trap method ? Thank you very much for your help (I'm new to Ruby) ! >> > > > I wouldn't do that, unless I had a need to inline it (e.g. writing a one-liner on the the command line), but I also wouldn't care enough to change it if I saw it in my codebase. It is totally irrelevant next to concerns about object boundaries and mutability, so it seems to me that any disagreement is just bikeshedding. > The thing I don't like about using .tap in the way sown is that it feels like a side effect, but admittedly that comes from my initial belief about the intention of .tap. As with most things, we find new uses for things that weren't originally thought of, and I find that good for the most part. > > On Sun, Apr 21, 2013 at 1:20 PM, Love U Ruby wrote= : >> >> Can on the same context anyone explain the difference between `tap` and >> `inject` ? >> > > Are the docs unclear? --14dae9473a79720eb404daf20703 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Apr 21, 2013 5:21 PM, "Josh Cheek" <josh.cheek@gmail.com> wrote:
>
> On Sun, Apr 21, 2013 at 12:56 AM, S=C3=A9bastien Durand <lists@ruby-forum.com> wrote:
>>
>>
>> What is the Ruby way of doing this ? Is it common to use this
>> trap method ? Thank you very much for your help (I'm new to Ru= by) !
>>
>
>
> I wouldn't do that, unless I had a need to inline it (e.g. writing= a one-liner on the the command line), but I also wouldn't care enough = to change it if I saw it in my codebase. It is totally irrelevant next to c= oncerns about object boundaries and mutability, so it seems to me that any = disagreement is just bikeshedding.
>

The thing I don't like about using .tap in the way sown is that it f= eels like a side effect, but admittedly that comes from my initial belief a= bout the intention of .tap. As with most things, we find new uses for thing= s that weren't originally thought of, and I find that good for the most= part.

>
> On Sun, Apr 21, 2013 at 1:20 PM, Love U Ruby=C2=A0<lists@ruby-forum.com>=C2=A0wrote:
>>
>> Can on the same context anyone explain the difference between `tap= ` and
>> `inject` ?
>>
>
> Are the docs unclear?

--14dae9473a79720eb404daf20703--