Reputation: 928
I have an array
Numbers =[
[
[ [1], [2] ],
[ [3], [4] ],
],
[
[ [5], [6] ],
[ [7], [8] ]
]
]
I want to get the results like this
[ [ [1], [2] ],[ [3], [4] ]]
and
[ [ [5], [6] ],[ [7], [8] ]]
in Ruby.
Is that possible?
Python equivalent is
for Number in Numbers:
print Number
Upvotes: 0
Views: 148
Reputation: 434965
Numbers.each { |n| puts n.inspect }
For example:
>> Numbers.each { |n| puts n.inspect }
[[[1], [2]], [[3], [4]]]
[[[5], [6]], [[7], [8]]]
BTW, technically you have an array of arrays or arrays, there are no multi-dimensional Arrays in Ruby (unless you create your own class to implement them of course).
Upvotes: 3
Reputation: 21791
Equivalent to Python style:
for number in Numbers do
p number
end
#=>
[[[1], [2]], [[3], [4]]]
[[[5], [6]], [[7], [8]]]
Upvotes: 1