Module.nesting strangeness

Discussion in 'Ruby' started by Alexandre Mutel, Nov 26, 2009.

  1. Hi,
    i'm encountering a weird behavior of the Module.nesting methodd. Here is
    my testcase from the irb:

    ____________________________

    class A
    class B
    def test()
    puts "Module.nesting : " + Module.nesting * ","
    end
    end
    end
    => nil

    b = A::B.new
    => #<A::B:0x24102d8>

    b.test
    Module.nesting : A::B,A
    => nil

    b.instance_eval { puts "Module.nesting : " + Module.nesting * "," }
    Module.nesting :
    => nil
    ____________________________

    The documentation says : "Returns the list of Modules nested at the
    point of call. ". But how Module.nesting in test() method knows that it
    was declared inside the class A/classB and not outside?
    --
    Posted via http://www.ruby-forum.com/.
    Alexandre Mutel, Nov 26, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tobiah

    csv module strangeness.

    tobiah, Aug 30, 2006, in forum: Python
    Replies:
    16
    Views:
    685
    tobiah
    Aug 31, 2006
  2. tow
    Replies:
    8
    Views:
    289
    Peter Otten
    Aug 12, 2008
  3. Brian Marick
    Replies:
    7
    Views:
    137
    George Marrows
    Apr 14, 2004
  4. gga
    Replies:
    3
    Views:
    146
    William Morgan
    Feb 19, 2005
  5. Trans
    Replies:
    10
    Views:
    286
    Sean O'Halpin
    Sep 16, 2005
Loading...

Share This Page