From: Robert Klemme Date: 2013-04-23T23:52:43+09:00 Subject: Re: Tap method : good or bad practice ? --14dae9399b0353872c04db0856a3 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Apr 23, 2013 at 12:05 PM, Michel Demazure wrote: > tamouse mailing lists wrote in post #1106508: > > > 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. > > I often find myself using idioms like > > Klass.new.tap do > ... > end > That doesn't make any sense at all: there is no point in using #tap if you do not assign the result and not use the block parameter. (Note: #tap does not change self.) Or do you mean Klass.new.instance_eval do ... end > with Klass = Hash, Array, ... , and dreaming about a shortcut to > 'new.tap' like 'such_that', 'with', ... > What is it that you want to achieve? Can you please come up with a more realistic example? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --14dae9399b0353872c04db0856a3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Tue, Apr 23, 2013 at 12:05 PM, Michel Demazure <lists@ruby-f= orum.com> wrote:
tamouse mailing lists wrote in post #1106508= :

> 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 thing= s
> that weren't originally thought of, and I find that good for the m= ost
> part.

I often find myself using idioms like

Klass.new.tap do
...
end

That doesn't make any sen= se at all: there is no point in using #tap if you do not assign the result = and not use the block parameter. =A0(Note: #tap does not change self.) =A0O= r do you mean

Klass.new.instance_eval do
= ...
end
=A0
with Klass =3D Hash, Array, ... , and dreaming about a shortcut to
'new.tap' like 'such_that', 'with', ...

What is it that you want to achieve? =A0Can = you please come up with a more realistic example?

Kind regar= ds

robert

--
remember.guy do |as, often| as.you_can -= without end
http://blog.= rubybestpractices.com/
--14dae9399b0353872c04db0856a3--