From: Robert Klemme Date: 2009-03-26T01:50:10+09:00 Subject: Re: appending an array to a frozen array 2009/3/25 James French : > Ah, I understand - thanks. My next question is - is it possible to prevent this? Since you are using an instance variable you control how it is accessed. So, yes. If you want to know whether there is a hard way to prevent reassignment to instance variables, the only safe way I know off the top of my head is to freeze the owner: irb(main):001:0> o=Object.new => # irb(main):002:0> o.instance_variable_set "@foo", 1 => 1 irb(main):003:0> o => # irb(main):004:0> o.freeze => # irb(main):005:0> o.instance_variable_set "@foo", 2 RuntimeError: can't modify frozen object from (irb):5:in `instance_variable_set' from (irb):5 from /opt/bin/irb19:12:in `
' irb(main):006:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end