Why NameError ??

Discussion in 'Ruby' started by Kyung won Cheon, Aug 25, 2008.

  1. module M1
    class A
    end
    end

    module M2
    class A
    end
    p A # M2::A
    class B
    p A # M2::A
    end
    end

    module M3
    include M1
    p A # M1::A
    class B
    p A # NameError (M3::B::A)
    end
    end

    ##############
    # Help Me^^
    ##############
    --
    Posted via http://www.ruby-forum.com/.
    Kyung won Cheon, Aug 25, 2008
    #1
    1. Advertising

  2. [Note: parts of this message were removed to make it a legal post.]

    it seems that the interpreter search for a 'A' class nested inside B ... I
    don't know why..

    On Mon, Aug 25, 2008 at 8:54 AM, Kyung won Cheon <>wrote:

    > module M1
    > class A
    > end
    > end
    >
    > module M2
    > class A
    > end
    > p A # M2::A
    > class B
    > p A # M2::A
    > end
    > end
    >
    > module M3
    > include M1
    > p A # M1::A
    > class B
    > p A # NameError (M3::B::A)
    > end
    > end
    >
    > ##############
    > # Help Me^^
    > ##############
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >



    --
    Go outside! The graphics are amazing!
    Sandro Paganotti, Aug 25, 2008
    #2
    1. Advertising

  3. Kyung won Cheon

    Robert Dober Guest

    On Mon, Aug 25, 2008 at 10:54 AM, Kyung won Cheon <> wrote:
    constants are not included, only methods
    HTH
    Robert

    --
    http://ruby-smalltalk.blogspot.com/

    There's no one thing that's true. It's all true.
    --
    Ernest Hemingway
    Robert Dober, Aug 25, 2008
    #3
    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. GMTaglia

    NameError

    GMTaglia, Oct 5, 2004, in forum: Python
    Replies:
    2
    Views:
    2,731
    GMTaglia
    Oct 5, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    880
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,844
    Smokey Grindel
    Dec 2, 2006
  4. seancron

    nameerror upon calling function

    seancron, Sep 1, 2007, in forum: Python
    Replies:
    1
    Views:
    351
    Arnaud Delobelle
    Sep 1, 2007
  5. Replies:
    10
    Views:
    459
Loading...

Share This Page