I have the following array:
arr = [0, 1, 1, 2, 3, 1, 0, 0, 1]
Without changing the order of the values, I need to subdivide arrinto smaller arrays in each case 0, so that the result is:
arr = [ [0, 1, 1, 2, 3, 1], [0], [0, 1] ]
If there arrwas a string, I could use .split("0")and then add a separator to each subarray. What would be the most efficient equivalent .split()in plain Ruby for arrays?
source
share