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.
fnums = [ 10, 20, [30, [40, 50] ] ] print "Original array:\n" print fnums nums = fnums.flatten print "\nFlatten array:\n" print nums
Original array: [10, 20, [30, [40, 50]]] Flatten array: [10, 20, 30, 40, 50]
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?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework