From: Fuad Saud Date: 2013-09-11T13:55:33-03:00 Subject: [ruby-core:57144] Re: [CommonRuby - Feature #8896] #tap with missing block --5230a085_643c9869_208 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline #tap without a block returning self makes sense -- Fuad Saud Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Wednesday, September 11, 2013 at 1:54 PM, prijutme4ty (Ilya Vorontsov) wrote: > > Issue #8896 has been updated by prijutme4ty (Ilya Vorontsov). > > > > I would like to see tap return an Enumerator if a block is not passed. > Can you explain your suggestion a bit more? I can't imagine realization and use-case yet. > ---------------------------------------- > Feature #8896: #tap with missing block > https://bugs.ruby-lang.org/issues/8896#change-41756 > > Author: prijutme4ty (Ilya Vorontsov) > Status: Open > Priority: Normal > Assignee: > Category: > Target version: > > > In case when no block provided to tap, it fails. So if you want method which can be called with or without block - you can't do it like this: > > def self.create(args={}, &block) > new.set_attributes(args).tap(&block) > end > > but should use block_defined? to prevent #tap's failure. > > I suggest to make tap with no block given just to return self and raise no errors. > > > > -- > http://bugs.ruby-lang.org/ > > --5230a085_643c9869_208 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
=23tap without a block returning self makes sense

-- 
=46uad Saud
Sent with S= parrow

=20

On Wednesday, Septembe= r 11, 2013 at 1:54 PM, prijutme4ty (Ilya Vorontsov) wrote:


Issue =238896 has= been updated by prijutme4ty (Ilya Vorontsov).

<= br>
I would like to see tap retur= n an Enumerator if a block is not passed.
Can you = explain your suggestion a bit more=3F I can't imagine realization and use= -case yet.
----------------------------------------
=46= eature =238896: =23tap with missing block

Author: prijut= me4ty (Ilya Vorontsov)
Status: Open
Priority: Normal<= /div>
Assignee:
Category:
Target version:


In case when no block provided to tap= , it fails. So if you want method which can be called with or without blo= ck - you can't do it like this:

def self.create(= args=3D=7B=7D, &block)
new.set=5Fattributes(args).tap(&am= p;block)
end

but should use block=5Fde= fined=3F to prevent =23tap's failure.

I suggest = to make tap with no block given just to return self and raise no errors.<= /div>



--
=20 =20 =20 =20
=20

--5230a085_643c9869_208--