0

nested array

inside the following array : [5,[9,4,6],[8]], how can we obtain the output of 5?

12th Nov 2016, 2:39 PM
Carlos Gonçalves Jorge
Carlos Gonçalves Jorge - avatar
5 Respostas
+ 11
the array is structured as following 0 1 2 0 5 N N 1 9 4 6 2 8 N N where N is an uninitialized memory so row 0 and column 0 will have the value 5 so if the array name is ar, then arr[0][0] will return the value 5
12th Nov 2016, 2:58 PM
Burey
Burey - avatar
+ 10
Good answer, Burey !
27th Nov 2016, 6:17 PM
Jose
+ 4
It was a good question 😬
27th Nov 2016, 6:29 PM
Burey
Burey - avatar
0
b = [5,[9,4,6],[8]] p b[0] #=> 5 p b[1] #=> [9,4,6] p b[2] #=> [8] p b[2][0] #=> 8
20th Jan 2017, 2:06 PM
つーく
0
arr = [5,[9,4,6],[8]] puts arr[0]
25th Jan 2017, 5:02 AM
Dario Silva
Dario Silva - avatar