From: "phluid61 (Matthew Kerwin)" Date: 2013-06-24T09:02:13+09:00 Subject: [ruby-core:55618] [ruby-trunk - Feature #6373] public #self Issue #6373 has been updated by phluid61 (Matthew Kerwin). headius (Charles Nutter) wrote: > Another option based on matz's objection: #reference. We want a method that returns the reference to the object we're calling against. #reference seems logical. > > [1,2,3,4,5,1,2,2,3].group_by(&:reference) +1. It's sensible (i.e. anyone who knows OOP knows what 'reference' means), there's no overloading of names, and the intention is clear. > So defining tap such that it defaults to a no-op function (i.e. does not yield if block not given) seems perfectly valid to me. I know I'm throwing a lot of paint at this shed, but while I agree that a default noop #tap is valid, I still strongly believe it makes ary.group_by(&:tap) seem like voodoo. I like #reference a lot. ---------------------------------------- Feature #6373: public #self https://bugs.ruby-lang.org/issues/6373#change-40107 Author: trans (SYSTEM ERROR) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =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/