Feature #1431

Object#__class__

Added by Sven Schwyn about 6 years ago. Updated about 4 years ago.

[ruby-core:23355]
Status:Rejected
Priority:Low
Assignee:Yukihiro Matsumoto

Description

=begin
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.
=end

History

#1 Updated by Yuki Sonoda almost 6 years ago

  • Assignee set to Yukihiro Matsumoto
  • Priority changed from Normal to Low
  • Target version set to 2.0.0

=begin

=end

#2 Updated by Marc-Andre Lafortune over 5 years ago

=begin
-1 because:

a) class is more keystrokes (if you count the shift key)
b) self.class is clear (and exists currently)
c) I feel that something should ideally be reserved for special cases; self.class isn't. I am aware that FILE was used a lot before and there's talk about dir, but I think that require_relative is now a better solution for most of these cases.
=end

#3 Updated by Yui NARUSE over 5 years ago

  • Status changed from Open to Rejected

=begin

=end

Also available in: Atom PDF