reloading required modules in irb

Discussion in 'Ruby' started by Heikki Kupiainen, Aug 6, 2006.

  1. Hi,

    I use irb to evaluate my code while programming.
    So it is easy to test my class this way:

    > require "my_class"
    > c = MyClass.new
    > c.some_method


    But the problem occurs when I now edit the class adding a new method
    "new_method". If I then type:

    > c.new_method

    NoMethodError: undefined method :'new_method'

    How can i now re-require "my_class" without restarting irb?
    typing again the require command doesn't seem to reload MyClass:

    > require "my_class"


    Nothing happens! The class is not reloaded into memory.

    Please tell me somebody how I can refresh the required class!



    --
    Posted via http://www.ruby-forum.com/.
     
    Heikki Kupiainen, Aug 6, 2006
    #1
    1. Advertising

  2. On Aug 6, 2006, at 9:03 AM, Heikki Kupiainen wrote:

    > Hi,
    >
    > I use irb to evaluate my code while programming.
    > So it is easy to test my class this way:
    >
    >> require "my_class"
    >> c = MyClass.new
    >> c.some_method

    >
    > But the problem occurs when I now edit the class adding a new method
    > "new_method". If I then type:
    >
    >> c.new_method

    > NoMethodError: undefined method :'new_method'
    >
    > How can i now re-require "my_class" without restarting irb?
    > typing again the require command doesn't seem to reload MyClass:
    >
    >> require "my_class"

    >
    > Nothing happens! The class is not reloaded into memory.
    >
    > Please tell me somebody how I can refresh the required class!
    >


    load "myclass.rb"


    >
    >
    > --
    > Posted via http://www.ruby-forum.com/.
    >
     
    Logan Capaldo, Aug 6, 2006
    #2
    1. Advertising

  3. > require "my_class"
    >
    > Nothing happens! The class is not reloaded into memory.


    #".delete("my_class")
    require "my_class"

    gegroet,
    Erik V. - http://www.erikveen.dds.nl/
     
    Erik Veenstra, Aug 6, 2006
    #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. Andy Jewell

    Reloading nested modules

    Andy Jewell, Jul 13, 2003, in forum: Python
    Replies:
    2
    Views:
    319
    Martin v. =?iso-8859-15?q?L=F6wis?=
    Jul 14, 2003
  2. OKB (not okblacke)

    Importing/reloading modules

    OKB (not okblacke), Sep 4, 2003, in forum: Python
    Replies:
    0
    Views:
    312
    OKB (not okblacke)
    Sep 4, 2003
  3. Joseph Krauze

    reloading modules

    Joseph Krauze, Dec 3, 2003, in forum: Python
    Replies:
    0
    Views:
    309
    Joseph Krauze
    Dec 3, 2003
  4. aurora
    Replies:
    2
    Views:
    294
    Bryan
    Oct 16, 2004
  5. Peter Peyman Puk

    Importing v reloading modules modules

    Peter Peyman Puk, Mar 19, 2010, in forum: Python
    Replies:
    0
    Views:
    318
    Peter Peyman Puk
    Mar 19, 2010
Loading...

Share This Page