From: Ross Bamford Date: 2006-03-23T01:25:46+09:00 Subject: Re: why doesn't "to_s" DWIM? On Thu, 2006-03-23 at 01:18 +0900, Chris McMahon wrote: > How come to_s doesn't work here? > > #################################### > require 'test/unit' > class TOY_CASE > def test_toy_test > > aoa = [[1,2,3],[4,5,6]] > > aoa.each do |arr| > arr.each do |item| > item = item.to_s > end > assert_equal(["1","2","3"],arr) > end > > > end #def > end #class > ########################################## Each just iterates the items, and the 'items' argument to the block is a new local variable - changing it has no lasting effect. Try map instead (here I use map! to change this array, rather than creating a new one): ########################################## require 'test/unit' class TOY_CASE