Question from the Kotlin test

Write a function that takes a list of strings and returns a list of the same length, where each element is the length of the corresponding element in the input list.

Hard

repeat is the following standard library function:

inline fun repeat(times: Int, action: (Int) -> Unit)
Executes the given function action specified number of times.
A zero-based index of current iteration is passed as a parameter to action.

Looking at the following codes :

repeat(3) {
    println("Hello")
}
repeat(3) { index ->
    println("Hello with index $index")
}
repeat(3,  index -> println("Hello with index $index") )
repeat(3, { println("Hello with index $it") })

Which of the following statements is true?

Author: W3D TeamStatus: PublishedQuestion passed 558 times
Edit
1
Community EvaluationsNo one has reviewed this question yet, be the first!