Project

General

Profile

Actions

Feature #767

closed

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

Added by rubikitch (rubikitch .) over 15 years ago. Updated almost 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 #1

Updated by matz (Yukihiro Matsumoto) over 15 years ago

=begin
まつもと ゆきひろです

In message "Re: [ruby-dev:37132] [Feature #767] Module#const_getでネストした定数の値を得られてもよいと思う"
on Fri, 21 Nov 2008 08:14:31 +0900, "rubikitch ." writes:

|Feature #767: Module#const_getでネストした定数の値を得られてもよいと思う
|Object#const_getでネストした定数を得られてもいいと思うのですが、どうでしょうか?

うーん、それが便利なことがあるのは認めますが、「あるクラスに
所属する定数」という概念を疎外する結果にもなりませんか?

=end

Actions #2

Updated by ko1 (Koichi Sasada) over 15 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

Actions #3

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Target version set to 2.0.0

=begin

=end

Actions #4

Updated by naruse (Yui NARUSE) over 14 years ago

  • Status changed from Open to Rejected

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0