How do I get the index of a value from a Kotlin array?
My best solution right now is using:
val max = nums.max() val maxIdx = nums.indices.find({ (i)
With current Kotlin (1.0) you can use indexOf() extension function on arrays:
val x = arrayOf("happy","dancer","jumper").indexOf("dancer")
All extension functions for arrays are found in the api reference.
In your example:
val maxIdx = nums.indexOf(nums.max())