Issue #6721 has been updated by aleph1 (Elias Levy).


nobu (Nobuyoshi Nakada) wrote:
> I'm not against the feature itself, but don't like the name.

At its core this feature relates to method chaining and transforming the object, something that cannot be done with Object#tap.  

Some suggested names then:  transform, alter, mutate, map, morph.

map may be the best choice, as its already used in enumerables and this is a natural equivalent for single objects.  That said, it may lead to unnoticed bugs if someone thinks they are applying a map operation on an enumerable but for some reason they do so against some other object.  So maybe one of the other names is better to ensure such cases fail.
 

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

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/