https://kotlinlang.org logo
#getting-started
Title
# getting-started
a

Alan Lee

12/05/2023, 3:06 AM
Does
.sliceArray()
create a new array coping the original array or does it just keep a reference to it? That info is difficult to find. Also anyone know where I can find the actual source code for the implementation? Thanks.
e

ephemient

12/05/2023, 3:16 AM
the source should be linked in intellij, but you can also see it at https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/common/src/generated/_Arrays.kt
👍 1
and it's always a copy. arrays are nearly-primitive objects that don't have any mechanism for sharing slices of themselves
👍 1
a

Alan Lee

12/05/2023, 5:46 AM
@ephemient Thanks a lot.