reloading required modules in irb

  • Follow


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/.

0
Reply heikki.kupiainen (1) 8/6/2006 1:03:10 PM

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/.
>


0
Reply logancapaldo (886) 8/6/2006 1:15:29 PM


>  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/


0
Reply erikveen (244) 8/6/2006 9:16:44 PM

2 Replies
46 Views

(page loaded in 0.229 seconds)


Reply: