On 22 Jul 2008, at 11:45, Indra M. wrote: > Hi, > > I want to extend a complex, multidimensional array with (code > snippet): > > results.each do |result| > result[1] << [string, array] > puts result[1] > end > puts results > > The output of "result[1]" is correct, showing the [string, array] is > attached. > But putting "results" shows, that "array" is not in "results". > > Does anyone no why? > -- > Posted via http://www.ruby-forum.com/. > You might have to post working code rather than a snippet. Putting in some test data seems to work fine in irb: irb(main):001:0> string = 'hi' => "hi" irb(main):002:0> array = [1,2,3] => [1, 2, 3] irb(main):003:0> results = [[0,[]],[0,[]]] => [[0, []], [0, []]] irb(main):004:0> results.each do |result| irb(main):005:1* result[1] << [string,array] irb(main):006:1> puts result[1] irb(main):007:1> end hi 1 2 3 hi 1 2 3 => [[0, [["hi", [1, 2, 3]]]], [0, [["hi", [1, 2, 3]]]]] irb(main):008:0> puts results 0 hi 1 2 3 0 hi 1 2 3 => nil Alex Gutteridge Department of Biochemistry University of Cambridge