[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:57465] [ruby-trunk - Feature #6721] Object#yield_self
From:       "abinoam (Abinoam P. Marques Jr.)" <abinoam () gmail ! com>
Date:       2013-09-29 11:04:19
Message-ID: redmine.journal-42080.20130929200418 () ruby-lang ! org
[Download RAW message or body]


Issue #6721 has been updated by abinoam (Abinoam P. Marques Jr.).


=begin
May I give a name suggestion? 
Does "tap!" make sense in english?

(({2.tap {|x| x*2 }})) ((|# => 2|))

(({2.tap! {|x| x*2 }})) ((|# => 4|))

The exclamation mark alerts that the return value is being changed.

=end

----------------------------------------
Feature #6721: Object#yield_self
https://bugs.ruby-lang.org/issues/6721#change-42080

Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


=begin
I think the following method is missing from Ruby:

 class Object
   def yield_self(*args)
     yield(self, *args)
   end
 end

I do not know a good use case, but it looks very natural to me.  It can be used in method chains.

What do you think?  Is there an alternative?
=end



-- 
http://bugs.ruby-lang.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic