>>>>> "S" == Simon Strandgaard <0bz63fz3m1qt3001 / sneakemail.com> writes:

S> Me don't understand.   If I add debug-print's to selftest then I see that
S> the parent *has* changed  ??   Can you enligthen me ?

svg% cat b.rb
#!/usr/bin/ruby
class A
   def initialize
      @value = [1, 2, 3]
      puts "#{self} -- #{@value.inspect}"
   end
   attr_reader :value
   def selftest
      if @value.size == 3
         puts "OK"
      else
         puts "Watch out, we have been modified"
         p @value
      end
      puts "#{self} -- #{@value.inspect}"
   end
end

class B < A
   def test1
      puts "#{self} -- #{@value.inspect}"
      objs = value
      objs << 4
      selftest
   end
   def test2
      puts "#{self} -- #{@value.inspect}"
      @value = [5, 6]
      selftest
   end
end

B.new.test1
B.new.test2
svg%
 
svg% b.rb
#<B:0x400992a4> -- [1, 2, 3]
#<B:0x400992a4> -- [1, 2, 3]
Watch out, we have been modified
[1, 2, 3, 4]
#<B:0x400992a4> -- [1, 2, 3, 4]
#<B:0x4009922c> -- [1, 2, 3]
#<B:0x4009922c> -- [1, 2, 3]
Watch out, we have been modified
[5, 6]
#<B:0x4009922c> -- [5, 6]
svg% 

 I don't see a parent nor a child : I just see an object which modify one
 of these instance variable.



Guy Decoux