Has a Module been defined?

Discussion in 'Ruby' started by Hadmut Danisch, Dec 14, 2003.

  1. Hi,

    how can I check whether a Module/Class with a given
    name has already been defined?

    regards
    Hadmut
     
    Hadmut Danisch, Dec 14, 2003
    #1
    1. Advertising

  2. Hadmut Danisch

    Hal Fulton Guest

    Hadmut Danisch wrote:
    > Hi,
    >
    > how can I check whether a Module/Class with a given
    > name has already been defined?


    Here is my first thought. There might be a problem with it,
    but it works on my simple tests.

    if defined?(Foo) && Foo.is_a?(Module)

    Hal
     
    Hal Fulton, Dec 14, 2003
    #2
    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. Kabeer
    Replies:
    6
    Views:
    3,286
    Thomas Matthews
    Aug 21, 2003
  2. BigMan
    Replies:
    8
    Views:
    366
    BigMan
    Feb 17, 2005
  3. Oodini
    Replies:
    1
    Views:
    1,838
    Keith Thompson
    Sep 27, 2005
  4. Randy Lawrence
    Replies:
    10
    Views:
    192
    Robert Klemme
    Jul 5, 2004
  5. Shriramana Sharma
    Replies:
    5
    Views:
    211
    Keith Thompson
    Apr 17, 2013
Loading...

Share This Page