Project

General

Profile

Actions

Feature #1431

closed

Object#__class__

Added by svoop (Sven Schwyn) over 15 years ago. Updated over 13 years ago.

Status:
Rejected
Target version:
[ruby-core:23355]

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0