比如说
arr = [1,2,3,4,5,6,7,8,9,10] # 得到如下数组 arr_per_four = [ [1,2,3,4], [5,6,7,8], [9,10] ] # 或者如下 arr_per_three = [ [1,2,3], [4,5,6], [7,8,9], [10] ]
请问怎么最简单?
arr.each_slice(n).to_a