Output of Iterable.sliding as Tuple
- by ziggystar
The method sliding on collections returns a sliding window of given size in the form of X[Iterable[A]] with X being the type of the collection and A the element type. Often I need two or three elements and I prefer to have them named. One ugly workaround for sliding(2) is the following:
points.sliding(2).foreach{ twoPoints =>
val (p1,p2)…