On 7/9/07, Ari Brown <ari / aribrown.com> wrote:
> But, I take it, I can't modify this single script, right?
>
> Start:
> file.rb
>
> so that after I download a new patch, all that's left is:
> file.rb

Yes, you can do that.

Also, like Diego mentioned about changing behavior of an object when
loading code ... say I have a file test.rb that looks like this:

class C
  def f(x)
    puts x
  end
end

and I go into irb ...

irb(main):001:0> load 'test.rb'
=> true
irb(main):002:0> c = C.new
=> #<C:0x2df909c>
irb(main):003:0> c.f 1
1
=> nil
irb(main):004:0> c.g 1
NoMethodError: undefined method 'g' for #<C:0x2df909c>
            from (irb):4

leaving irb sitting there just the way it is, I modify test.rb by
adding this method to class C:

def g x
  puts x + 1
end

back to irb...

irb(main):005:0> c.g 1
NoMethodError: undefined method 'g' for #<c:0x2df909c>
            from (irb):1
irb(main):006:0> load 'test.rb'  #reloading the file, but _not_ creating a new c
=> true
irb(main):007:0> c.g 1
2
=> nil

Todd