I have large list of objects and I need to split them in a group of two elements for UI propouse.
Example:
[0, 1, 2, 3, 4, 5, 6]
Becomes
Maybe not the most efficient solution, but the most direct solution:
func toPairs(numbers:[Int])->[[Int]] { var pairs:[[Int]]=[] var pair:[Int]=[] for var index=0;index
Output on my laptop:
[[0, 1], [2, 3], [4, 5]] Program ended with exit code: 0