Ruby Array Exercises: Concatenate array of arrays into one
Ruby Array: Exercise-16 with Solution
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
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook