Given
scala> val a = (1 to 9).toArray a: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9) would like to group elements in a in this way,
Array(Array(1,2,3), Array(4,5,6), Array(7,8,9)) Given
scala> val a = (1 to 9).toArray a: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9) would like to group elements in a in this way,
Array(Array(1,2,3), Array(4,5,6), Array(7,8,9)) If you want to get groups by 3 elements you could use method grouped:
a.grouped(3).toArray // Array(Array(1, 2, 3), Array(4, 5, 6), Array(7, 8, 9))