Ruby Language Initializing a 2D array


Example

Let's first recap how to initialize a 1D ruby array of integers:

my_array = [1, 1, 2, 3, 5, 8, 13]

Being a 2D array simply an array of arrays, you can initialize it like this:

my_array = [
  [1, 1, 2, 3, 5, 8, 13],
  [1, 4, 9, 16, 25, 36, 49, 64, 81],
  [2, 3, 5, 7, 11, 13, 17]
]