From: "headius (Charles Nutter)" Date: 2012-04-28T16:02:32+09:00 Subject: [ruby-core:44722] [ruby-trunk - Feature #6373] public #self Issue #6373 has been updated by headius (Charles Nutter). At first I found this laughable, but then I realized there's no clear method you can call against an object that simply returns the object. It is a small thing, but turns out to be very useful. For example, if you want a chain of method calls that successively transformation some data. Those transformations, in the form of folds or filters or what have you, may accept an object and return some new object by calling a method. In that case, the simplest transformation is to simply return the object unmodified. There is no such method on Object or BasicObject right now, so rather than having the uniformity of a method call you would need a special filter form that calls nothing and returns its one argument. Identity is an easy, simple functional form that should be available. I would suggest it should be called __self__ or similar, since it is a key core method nobody should ever override. But I do think there is utility in having it always available. ---------------------------------------- Feature #6373: public #self https://bugs.ruby-lang.org/issues/6373#change-26283 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 =begin This was recently suggested to me as an extension: class Object # An identity method that provides access to an object's 'self'. # # Example: # [1,2,3,4,5,1,2,2,3].group_by(&:identity) # #=> {1=>[1, 1], 2=>[2, 2, 2], 3=>[3, 3], 4=>[4], 5=>[5]} # def identity self end end First, is such a method commonly useful enough to warrant existence? Second, it makes me wonder if #self should be a public method in general. =end -- http://bugs.ruby-lang.org/