0
nested array
inside the following array : [5,[9,4,6],[8]], how can we obtain the output of 5?
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
+ 10
Good answer, Burey !
+ 4
It was a good question 😬
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
0
arr = [5,[9,4,6],[8]]
puts arr[0]