allDistinct

Returns true if all elements in the sequence are distinct from each other, that is, no two elements are equal.

Returns true for an empty sequence.

The elements are compared using structural equality (==). The operation returns false as soon as a duplicate element is found.

For elements of floating-point types (Double, Float), NaN is considered equal to NaN, and -0.0 is considered not equal to 0.0, consistent with Double.equals and Float.equals.

The operation is terminal.

Since Kotlin

2.4

Samples


fun main() { 
   //sampleStart 
   println(sequenceOf<String>().allDistinct()) // true
println(sequenceOf("apple").allDistinct()) // true

println(sequenceOf("apple", "mango", "peach").allDistinct()) // true

println(sequenceOf("apple", "mango", "apple").allDistinct()) // false 
   //sampleEnd
}