Assume the following Kotlin example that maps the source set src
to a destination set dst
:
private val src: Set<String> = setOf("hello", "world")
private val dst: Set<Int> = src.map { it.length }.toSet()
This works fine. However, IntelliJ's code inspection suggests: Call chain on collection should be converted into 'Sequence':
Applying this suggestion results in
private val dst: Set<Int> = src.asSequence().map { it.length }.toSet()
What is the benefit of this?