How do I get to the actual stdlib-sources of - say - the
min()
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? 😅
i
ilya.gorbunov
08/04/2017, 11:55 AM
which 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.
h
horse_badorties
08/04/2017, 1:40 PM
I see, thank you, Ilya!
At first I was a bit let down because the (generated) code looks so Java-ish 😅
Copy code
val 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
Copy code
with(iterator()) {
if (!hasNext()) return null
var min = next()
forEach { if (min > it) min = it }
return min
}