Issue #10183 has been updated by zverok (Victor Shepelev).


> My guess is that self.class mostly appears in the context of metaprogramming.

Why? In simple inheritance, you may have cases like:

```ruby
self.class::CONST # the constant is redefined in subclasses

def clone_with_tricks(...)
  self.class.new(...) # produce exactly the same class as self
end
```
...and a lot of others.

----------------------------------------
Feature #10183: An alternative name for method `class`
https://bugs.ruby-lang.org/issues/10183#change-67644

* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
The method `class` is special in that it always has to have an explicit receiver in order to avoid crash with the keyword `class`. But this is very inconvenient. I have seen so many

    self.class

in codes. I propose that there should be an alternative name for this method so that it can be used with an implicit receiver, and the method name `class` should be gradually depricated.

As for the name, I have no clear idea. I can only think of `klass`, but perhaps someone else might come up with a better name.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>