Combine three arrays to create multi-dimensional array : Multidimensional Arrays « Array « Ruby






Combine three arrays to create multi-dimensional array


yrs = [ 2007, 2008, 2009 ]

days = [ 31, [28, 29], 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]

months = [ "Jn", "Fb", "Mr", "Ap", "Ma", "Ju", "Jl", "Au", "Sp", "Oc", "Nv", "Dc" ]
d3 = [ yrs, days, months ] # => => [[2007, 2008, 2009], [31, [28, 29], 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], ["Jn", "Fb", "Mr", "Ap", "Ma", "Ju", "Jl", "Au", "Sp", "Oc", "Nv", "Dc"]]

 








Related examples in the same category

1.What is a multi-dimensional Arrays
2.flatten a multi-demensional array
3.transpose a multi-demensional array
4.Size and elements in a two-dimensional array
5.Convert a two-dimensional array to a hash
6.Three dimensional array