From: Paul Lutus Date: 2006-10-23T04:20:15+09:00 Subject: Re: []= with moredimensional Arrays naPOLeon wrote: > I'm sorry for my horrible English, I'm German. Your English is much better than my German, so no problem. All we have to do is figure out how to communicate the fine points of Ruby code, but without any code. > Anyway, of course I meant multidimensional and I want to get e.g. > > 0000 10 0100 > 0000 and 01 to become 0010 > 0000 11 0110 > > The first Array is definded by Array.new(3, Array.new(4, 0)), the > others the same way. > I hope you understand the problem now. From the appearance of your example, it appears that you want to replace the contents of two middle columns in a 4x3 array with the contents of a 2x3 array. Yes? #!/usr/bin/ruby -w array1 = [ [ 0,0,0,0 ], [ 0,0,0,0 ], [ 0,0,0,0 ] ] array2 = [ [ 1,0 ], [ 0,1 ], [ 1,1 ] ] array1.each_index do |i| array1[i][1 .. 2] = array2[i] end p array1 output: [[0, 1, 0, 0], [0, 0, 1, 0], [0, 1, 1, 0]] If this isn't what you had in mind, we'll have to try again. -- Paul Lutus http://www.arachnoid.com