days.zipWithIndex.foreach { case(day, count) => println(s"$count is $day")}
This approach simplifies the process of iterating over collections with an automatically generated counter, enhancing code readability and efficiency.
[
add
]
[
|
|
...
]
days.zipWithIndex.foreach { case(day, count) => println(s"$count is $day")}
This approach simplifies the process of iterating over collections with an automatically generated counter, enhancing code readability and efficiency.