Arup Rakshit wrote in post #1139587:
> Xavier Noria wrote in post #1139583:
>> On Wed, Mar 12, 2014 at 9:40 AM, Arup Rakshit <lists / ruby-forum.com>
>
>> On the other hand that "X" is stored in the set of constants of the
>> singleton class of M::Z, let's call it S. M::Z::X looks for "X" in the
>> constants table of M::Z and its ancestors, since none of them is S, the
>> lookup fails.
>
> Okay. Got it.
>
> module M
>   class Z
>     Num = 10
>     class << self
>       Big = 11
>   def foo; 12 ; end
>     end
>   end
> end
>
> M::Z.singleton_class::Big # => 12

**Note for future readers** - There is a typo in the above line.

M::Z.singleton_class::Big # => 11 (not 12)

> M::Z.constants.grep(/Num/) # => [:Num]
>
> Why the below didn't give me [:Big] ?
>
> M::Z.singleton_class.constants.grep(/Big/) # => [:Bignum]

-- 
Posted via http://www.ruby-forum.com/.