allEqualBy
Returns true if all elements in the sequence yield the same value produced by the given selector function.
Returns true for an empty sequence.
The selector values are compared sequentially using structural equality (==), and all elements are considered equal by the selector value if the selector value of the first element equals the selector value of every subsequent element.
For selector values 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.4Samples
fun main() {
//sampleStart
println(sequenceOf<String>().allEqualBy { it.length }) // true
println(sequenceOf("apple").allEqualBy { it.length }) // true
println(sequenceOf("apple", "mango", "peach").allEqualBy { it.length }) // true
println(sequenceOf("apple", "mango", "peach").allEqualBy { it }) // false
//sampleEnd
}Content copied to clipboard