I noticed the existence of both files - I am new to the Kotlin ecosystem and I want a better understanding of the existing stdlib files (and not only..)
Currently I found that there are the following files: _ArraysJVM.kt and ArraysJVM.kt
What is the difference between them? Both of them reside in the kotlin.collections package and both contain utility functions. Can someone explain me why aren't these two in the same file?
Later Edit: One of them is generated, but it's quite confusing since the language is the same in both files. Why is one generated and the other not? :)
Looking at the Kotlin repo, ArraysJVM.kt
is located at:
/libraries/stdlib/jvm/src/kotlin/collections/ArraysJVM.kt
whereas _ArraysJvm.kt
is located at:
/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt
So the latter is a generated file, as the comment at the top says:
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
If you follow that link, you'll see the explanation for these files that are prefixed with underscores:
We use code generation to generate utility extension functions for some collection-like types like arrays, strings,
Collection<T>
,Sequence<T>
,Map<K, V>
etc.These sources are placed into the generated folder and their names are prefixed with an underscore, for example, generated/_Collections.kt