When parsing CSV file I need to combine fields of a row into an array starting from 4th field (3rd array element). I want to manipulate each row as in example below: Original array:
array1 = [1,2,3,4,5]
Changed array:
array2 = [1,2,3,[4,5]]
My code is here:
array1[0..2].push(array1[3..array1.length])
=> [1, 2, 3, [4, 5]]
My question is: Is there a better/cleaner/simpler way to convert part of an array into subarray?