+ 4

How to print nested array row by row?

Let say I have the following array: arr = [[2, 6], [3, 4]] Expected output: [2, 6] [3, 4] However, the following output appear instead. Code: print arr Output: [[2, 6], [3, 4]] Code: puts arr Output: 2 6 3 4

6th May 2017, 2:35 AM
SC Lee
SC Lee - avatar
2 ответов
+ 5
Thanks. Loops working great. for i in (0..arr.length-1) print arr[i] puts "\n" end
9th May 2017, 10:33 PM
SC Lee
SC Lee - avatar
+ 1
print arr[0] puts print arr [1] you can do with loops also.
9th May 2017, 4:51 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar