Using kotlin's `map` function on collections?

Kotlin offers the `map` function to transform each element in a collection based on a provided function. Here's how to use the map function:


  val words = listOf("a", "ab", "abc")
  val lengths = words.map { it.length }
  println(lengths)
  

Beginner's Guide to Kotlin