indra
July 22, 2008, 12:50pm
1
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?
indra
July 22, 2008, 1:13pm
2
On Tue, Jul 22, 2008 at 12:45 PM, Indra M. [email protected]
wrote:
The output of “result[1]” is correct, showing the [string, array] is
attached.
But putting “results” shows, that “array” is not in “results”.
But putting “result” might be more to your
liking.
HTH
Robert
–
http://ruby-smalltalk.blogspot.com/
There’s no one thing that’s true. It’s all true.
indra
July 22, 2008, 1:24pm
3
Robert D. wrote:
But putting “result” might be more to your
liking.
I don’t understand what you are meaning.
I have results to be extended.
indra
July 22, 2008, 1:40pm
4
On 22 Jul 2008, at 11:45, Indra M. wrote:
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 G.
Department of Biochemistry
University of Cambridge
indra
July 22, 2008, 2:09pm
5
On Tue, Jul 22, 2008 at 1:18 PM, Indra M. [email protected]
wrote:
Robert D. wrote:
But putting “result” might be more to your
liking.
I don’t understand what you are meaning.
I have results to be extended.
no
–
http://ruby-smalltalk.blogspot.com/
There’s no one thing that’s true. It’s all true.