From: benny Date: 2006-03-23T05:48:51+09:00 Subject: Re: why doesn't "to_s" DWIM? benny wrote: > > a = ["2","3", "4"] > a.each { |i| i.replace("#{i} times") } > p a > > in fact variables only point to the objects. so you might use them to > modify the object they are currently pointing to. if you got strings, you > may modify them (instead of creating new ones). but unfortunately that > won't > work for numbers, since they are no real objects, but - how do we call > them? - first level objects? so this would work also: aoa = [[1,2,3],[4,5,6]] aoa.each do |arr| arr.each_index do |i| arr[i] = arr[i].to_s end end p aoa > > benny > >