Is there a way to dynamically access a nested array using indices which are themselves stored in an array?
The main array/matrix nesting could be variable e.g. 2, 4,
Ruby 2.3.0 introduced a new method called dig on both Hash and Array that solves this problem.
Hash
Array
It returns nil if an element is missing at any level of nesting.
nil
my_array.dig(0,1,1)
[0, 1, 1].inject(my_array, :fetch) # => 4