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

List:       ruby-core
Subject:    [ruby-core:44773] [ruby-trunk - Feature #6373] public #self
From:       "trans (Thomas Sawyer)" <transfire () gmail ! com>
Date:       2012-04-30 17:03:32
Message-ID: redmine.journal-26337.20120501020331 () ruby-lang ! org
[Download RAW message or body]


Issue #6373 has been updated by trans (Thomas Sawyer).


Like many of Ruby's keywords, it can still be used to define a public method:

  class X
    def self; "x"; end
  end

   x = X.new
   x.self  #=> "x"

----------------------------------------
Feature #6373: public #self
https://bugs.ruby-lang.org/issues/6373#change-26337

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/

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

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