Project

General

Profile

Actions

Feature #11905

closed

Change the 'class' keyword to return a symbol

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

Status:
Closed
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 1 (1 open0 closed)

Related to Ruby master - Feature #8839: Class and module should return the class or module that was openedAssignedmatz (Yukihiro Matsumoto)Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 9 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 9 years ago

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

Updated by yuki24 (Yuki Nishijima) almost 9 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0