horse_badorties
08/04/2017, 6:36 AMmin()
function in Intellij?
When I do STRG-B
it loads _Collections.kt
from the generated
folder of the kotlin-stdlib-xxx-sources.jar
- which is not the actual source I guess. When I browse the kotlin\collections
folder instead I find CollectionsKt.class but this does not include the min()
function.
A "Search everywhere" doesn't help either.
What is this generated
folder about anyway? Who generates it and why? 😅ilya.gorbunov
08/04/2017, 11:55 AMwhich is not the actual source I guess.It's the actual source. However due to a significant code duplication between collections, arrays, sequences etc, the source of most collection operations is generated from a template.
horse_badorties
08/04/2017, 1:40 PMval iterator = iterator()
if (!iterator.hasNext()) return null
var min = iterator.next()
while (iterator.hasNext()) {
val e = iterator.next()
if (min > e) min = e
}
return min
I had expected something like
with(iterator()) {
if (!hasNext()) return null
var min = next()
forEach { if (min > it) min = it }
return min
}