From: Jonah Bloch-Johnson Date: 2008-08-20T08:16:22+09:00 Subject: Nested Arrays in Method Definitions--a puzzle Hello there Ruby-minded people! I am writing because I am somewhat stumped by why the following discrepency occurs; having defined the following: class Warfare def haves x = [1] y = [] y << x x = [2] # (compare this) y end def havenots x = [1] y = [] y << x x[0] = 2 # (to this) y end end I get this in irb: >> load 'snah.rb' => true >> a = Warfare.new => # >> a.haves => [[1]] >> a.havenots => [[2]] Why does meddling with the innards of the "x" have retroactive repercussions, whereas redefining it outright does not? Any insight would be greatly appreciated. -Jonah