From: furufuru@... (Ryo Furue) Date: 2001-08-11T19:43:29+09:00 Subject: [ruby-talk:19517] Why not?: Assigning to self Hi there, I wanted to add a "bang" method to the Array class: class Array def smooth! n = self.size res = Array.new (1..n-2).each { |i| res[i] = (self[i-1] + 2.0 * self[i] + ... } #self.each_index { |i| self[i] = res[i] } self = res end end The line "self = res" gives an error smooth:17: Can't change the value of self self = res So I resorted to the line which is commented out in the code above. But, why is it forbidden to assign to self? I think that assigning to self and throwing away the object originally referenced by self is more efficient than modifying the object referenced by self and throwing away the one referenced by "res". Am I missing something? Cheers, Ryo