Project

General

Profile

Actions

Feature #767

closed

Module#const_getでネストした定数の値を得られてもよいと思う

Added by rubikitch (rubikitch .) about 16 years ago. Updated over 13 years ago.

Status:
Rejected
Target version:
[ruby-dev:37132]

Description

=begin
Object#const_getでネストした定数を得られてもいいと思うのですが、どうでしょうか?

def my_const_get(name)
name.split(/::/).inject(Object){|o,c| o.const_get(c) }
end
my_const_get "File::Stat" # => File::Stat
Object.const_get "File::Stat" rescue $!

=> #<NameError: wrong constant name File::Stat>

=end


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #5690: Module#qualified_const_getClosedtenderlovemaking (Aaron Patterson)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0