distinct
fun <T> Array<out T>.distinct(): List<T>fun ShortArray.distinct(): List<Short>fun FloatArray.distinct(): List<Float>fun DoubleArray.distinct(): List<Double>fun BooleanArray.distinct(): List<Boolean>Returns a list containing only distinct elements from the given array.
The elements in the resulting list are in the same order as they were in the source array.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val list = listOf('a', 'A', 'b', 'B', 'A', 'a')
println(list.distinct()) // [a, A, b, B]
println(list.distinctBy { it.toUpperCase() }) // [a, b]
//sampleEnd
}Returns a list containing only distinct elements from the given collection.
The elements in the resulting list are in the same order as they were in the source collection.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val list = listOf('a', 'A', 'b', 'B', 'A', 'a')
println(list.distinct()) // [a, A, b, B]
println(list.distinctBy { it.toUpperCase() }) // [a, b]
//sampleEnd
}