``` for (lookupTask in lookupTasks) { val serv...
# getting-started
u
Copy code
for (lookupTask in lookupTasks) {
    val serverUrl = lookupTask.execute(domain, username, password)
    if (serverUrl != null) {
        return serverUrl
    }
}
return null
p
Copy code
return lookupTasks
	.asSequence()
	.mapNotNull { it.execute(domain, username, password) }
	.firstOrNull()
👍 2
u
doesnt really shortcut it, right?
a
what do you mean with "doesn't really shortcut it"? It's a sequence so it only does the mapping until it gets the first non null
u
really? Ill investigate, because im pretty sure normal list.mapNotNull does all the items and skips the null ones
a
Yes, that's the case with a normal list or w/e. But that's why @Pavlo Liapota had
asSequence()
. Because they are a "lazy collection" like java's
Stream
See https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/index.html