Project

General

Profile

Feature #11905

Change the 'class' keyword to return a symbol

Added by yuki24 (Yuki Nishijima) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:72546]

Description

Currently the class keyword returns nil:

class Person; end # => nil

It would be great if it could return a symbol instead:

class Person; end # => :Person

If we make it so we'll be able to do something like below:

private_constant class User
  ...
end

Related issues

Related to Ruby master - Feature #8839: Class and module should return the class or module that was openedAssignedActions

History

#1

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • Related to Feature #8839: Class and module should return the class or module that was opened added

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

It returns the last value inside the block, as well as begin/end block, not nil.

Updated by yuki24 (Yuki Nishijima) almost 4 years ago

  • Status changed from Open to Closed

I am totally aware of the current behaviour that you mentioned, but I'll close this issue since this is a duplicate.

Also available in: Atom PDF