flatten to remove all arrays

We have an array which contains other arrays. We want to keep all the items of the array but we want to remove all the arrays. Ruby provides flatten to do this job.

As we can see array2 does not have any array element. Note that flatten does not change original array. The original array1 is still containing array items.