...

/

Arrays of Arrays: Two-dimensional arrays

Arrays of Arrays: Two-dimensional arrays

Learn about 2D arrays and how they are used in Ruby.

We'll cover the following...

Initializing different types of arrays

We can specify any type while initializing arrays. For example, string:

$ irb
> Array.new(10, 'hello')
=> ["hello", "hello", "hello", "hello", "hello", "hello", "hello", "hello", "hello", "hello"]

Or Boolean:

Note: Boolean type doesn’t exist in Ruby but, in this course, we intentionally refer to both theTrueClass and FalseClass types as Boolean.

$ irb
> Array.new(10, true)
=> [true, true, true, true, true, true, true, true, true, true]

Or integer:

$ irb
> Array.new(10, 123)
=> [123, 123, 123, 123, 123, 123, 123, 123, 123,
...