Feature #1431: Object#__class__
http://redmine.ruby-lang.org/issues/show/1431

Author: Sven Schwyn
Status: Open, Priority: Normal
Category: core

Consider the following code using class instance variables:

class Car
  def self.total_count=(n)
    @total_count = n
  end

  def initialize
    self.class.total_count = 0
  end
end

The compile requires "self.class.total_count" as the more readable "class.total_count" is mistaken by the parser as a faulty class definition.

How about adding a __class__ method to Object?

class Object
  def __class__
    self.class
  end
end

It would allow the use of "__class__" as a de facto prefix for class instance variables and would fit e.g. the id/__id__ and send/__send__ paradigm.


----------------------------------------
http://redmine.ruby-lang.org