code
scala – iterate through elements of collection with their indexes
On 23, Jun 2011 | No Comments | In code | By admin
I finally discovered a nice syntax for iterating through a collection with the indices of each element provided:
List(9,9,9,9,9,9).zipWithIndex
res0: List[(Int, Int)] = List((9,0), (9,1), (9,2), (9,3), (9,4), (9,5))
Submit a Comment