Roberto Messina
09/23/2019, 9:10 AMgildor
09/23/2019, 9:12 AMRoberto Messina
09/23/2019, 9:18 AMgildor
09/23/2019, 9:59 AMwithout exstension to learn sintax and languagesIsn’t stdlib functions is part of language and syntax?
i find kotlin’s extensions?What do you mean? Extension function is just a language feature: https://kotlinlang.org/docs/reference/extensions.html Standard library contains a lot of them, just check reference. For example this is doc for package
kotlin.collections
which contains a lot of extensions for different types, including `Array.reverse()`:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/index.htmlprintArray
or printStringArray
you can just use array extension *Array.contentToString()
reverseArray
implementation and it’s expected that it’s not working, you use for
loop in a wrong way. Not clearly sure what you try to achieve, you probably need range, because your code just iterate array with index and var nMiddle
just not used (because one in for loop doesn’t override it). And use withIndex
is not very efficcient way to work with arrays, it creates a lot of overhead (one additional object on every item) for case which can be easily solved without it
But maybe you just need range, or something like this:
for (i in (0..nMiddle))