Is there any List/Sequence built-in that behaves like map and provides the element\'s index as well?
map
Use .map in .zipWithIndex
val myList = List("a", "b", "c") myList.zipWithIndex.map { case (element, index) => println(element, index) s"${element}(${index})" }
Result:
List("a(0)", "b(1)", "c(2)")