Ruby Array Exercises: Concatenate array of arrays into one
Write a Ruby program to concatenate array of arrays into one.

Ruby Code:
fnums = [ 10, 20, [30, [40, 50] ] ]
print "Original array:\n"
print fnums
nums = fnums.flatten
print "\nFlatten array:\n"
print nums
Output:
Original array: [10, 20, [30, [40, 50]]] Flatten array: [10, 20, 30, 40, 50]
Flowchart:

Ruby Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Ruby program to create an array of length 2 containing their middle elements from two given arrays of integers and length 3.
Next: Write a Ruby program to check whether an given array of integers of length 2 contains a 4 or a 7.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics