From: Nelson Wong Date: 2002-03-08T06:32:44+09:00 Subject: RE: Loading ruby file in irb Thank you so much, Pete, it was a great help! I tried the command "Ruby irb" and then "load" in MS command prompt, it loads me the right files as long as the files are in the bin directory. However, it would notload the files, when I use RubyWin. I wonder where is the default source code directory in RubyWin. Thanks!! Nelson -----Original Message----- From: Pete McBreen [mailto:pete@mcbreen.ab.ca] Sent: Wednesday, March 06, 2002 7:37 PM To: ruby-talk@ruby-lang.org Subject: Re: Loading ruby file in irb Nelson Wong wrote << wonder how do I load Ruby files at irb on a fly?>> D:\Ruby\bin>ruby irb irb(main):001:0> load "OdometerTest.rb" "012345" "00100000" true irb(main):002:0> exit require "OdometerTest.rb" would do a similar thing but it only loads a file one, whereas load "file.rb" loads the file every time. <> No problem, you can even dynamically add or redefine methods in classes. It is perfectly legal (and very useful) to just give a partial definition of a class at a irb prompt (and in ruby directly) to replace the definition of just that method, or to add a new method... class Odometer def increment @wheels.last.increment end end cheers, Pete ---- Pete McBreen, McBreen.Consulting , Cochrane, AB email: petemcbreen@acm.org http://www.mcbreen.ab.ca/ Author, "Software Craftsmanship The New Imperative" Addison-Wesley (C) 2002 http://www.amazon.com/exec/obidos/ASIN/0201733862 Finalist for the 2002 Jolt Awards