How to create two dimensional array in ruby?

Ruby doesn't have any class like two dimensional Array.
The combination of 1dimensional array will called TWo dimensional array.

Let's create Two dimensional array

Syntax

Array = [ [val1,val2], [val3,val4], ... ]

 

Example

# a two-dimensional array declaration

arr = [[1,2],[2,3],['Sachin','India'],['Pointing','Australia']]

# printing

puts "The two dimensional Array elements are:"

print arr

 

Output

The two dimensional Array elements are:
[[1, 2], [2, 3], ["Sachin", "India"], ["Pointing", "Australia"]]

 

Creating Two Dimensional Array with Array.new() method

Syntax:

 array_name = Array.new(size, Array.new)