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<Test::Unit::TestCase
> 
> 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<Test::Unit::TestCase

  def test_toy_test

    aoa = [[1,2,3],[4,5,6]]

    aoa.each do |arr|
      arr.map! do |item|
        item.to_s
      end
    end

    assert_equal [["1","2","3"],["4","5","6"]], aoa
  end #def
end #class
##########################################

Notice too I changed the way your assertion works, since it would fail
on the second array if tested against ["1","2","3"].

-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk