allEqualBy
Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(arrayOf<String>().allEqualBy { it.length }) // true
println(arrayOf("apple").allEqualBy { it.length }) // true
val values = arrayOf("apple", "mango", "peach")
println(values.allEqualBy { it.length }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(byteArrayOf().allEqualBy { it * it }) // true
println(byteArrayOf(1).allEqualBy { it * it }) // true
val values = byteArrayOf(1, -1, 1)
println(values.allEqualBy { it * it }) // true
println(values.allEqualBy { abs(it.toInt()) }) // true
println(values.allEqualBy { it * it * it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(shortArrayOf().allEqualBy { it * it }) // true
println(shortArrayOf(1).allEqualBy { it * it }) // true
val values = shortArrayOf(1, -1, 1)
println(values.allEqualBy { it * it }) // true
println(values.allEqualBy { abs(it.toInt()) }) // true
println(values.allEqualBy { it * it * it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(intArrayOf().allEqualBy { it * it }) // true
println(intArrayOf(1).allEqualBy { it * it }) // true
val values = intArrayOf(1, -1, 1)
println(values.allEqualBy { it * it }) // true
println(values.allEqualBy { abs(it) }) // true
println(values.allEqualBy { it * it * it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(longArrayOf().allEqualBy { it * it }) // true
println(longArrayOf(1L).allEqualBy { it * it }) // true
val values = longArrayOf(1L, -1L, 1L)
println(values.allEqualBy { it * it }) // true
println(values.allEqualBy { abs(it) }) // true
println(values.allEqualBy { it * it * it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(floatArrayOf().allEqualBy { it * it }) // true
println(floatArrayOf(1.0f).allEqualBy { it * it }) // true
val values = floatArrayOf(1.0f, -1.0f, 1.0f)
println(values.allEqualBy { it * it }) // true
println(values.allEqualBy { abs(it) }) // true
println(values.allEqualBy { it * it * it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(doubleArrayOf().allEqualBy { it * it }) // true
println(doubleArrayOf(1.0).allEqualBy { it * it }) // true
val values = doubleArrayOf(1.0, -1.0, 1.0)
println(values.allEqualBy { it * it }) // true
println(values.allEqualBy { abs(it) }) // true
println(values.allEqualBy { it * it * it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(booleanArrayOf().allEqualBy { 0 }) // true
println(booleanArrayOf(true).allEqualBy { 0 }) // true
val values = booleanArrayOf(true, false, true)
println(values.allEqualBy { 0 }) // true
println(values.allEqualBy { if (it) 1 else 0 }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(charArrayOf().allEqualBy { it.uppercaseChar() }) // true
println(charArrayOf('a').allEqualBy { it.uppercaseChar() }) // true
val values = charArrayOf('a', 'A', 'a')
println(values.allEqualBy { it.uppercaseChar() }) // true
println(values.allEqualBy { it.lowercaseChar() }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}Returns true if all elements in the collection yield the same value produced by the given selector function.
Returns true for an empty collection.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(listOf<String>().allEqualBy { it.length }) // true
println(listOf("apple").allEqualBy { it.length }) // true
val values = listOf("apple", "mango", "peach")
println(values.allEqualBy { it.length }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(uintArrayOf().allEqualBy { it % 2u }) // true
println(uintArrayOf(1u).allEqualBy { it % 2u }) // true
val values = uintArrayOf(1u, 3u, 5u)
println(values.allEqualBy { it % 2u }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ulongArrayOf().allEqualBy { it % 2uL }) // true
println(ulongArrayOf(1uL).allEqualBy { it % 2uL }) // true
val values = ulongArrayOf(1uL, 3uL, 5uL)
println(values.allEqualBy { it % 2uL }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ubyteArrayOf().allEqualBy { it.toUInt() % 2u }) // true
println(ubyteArrayOf(1u).allEqualBy { it.toUInt() % 2u }) // true
val values = ubyteArrayOf(1u, 3u, 5u)
println(values.allEqualBy { it.toUInt() % 2u }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}Returns true if all elements in the array yield the same value produced by the given selector function.
Returns true for an empty array.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ushortArrayOf().allEqualBy { it.toUInt() % 2u }) // true
println(ushortArrayOf(1u).allEqualBy { it.toUInt() % 2u }) // true
val values = ushortArrayOf(1u, 3u, 5u)
println(values.allEqualBy { it.toUInt() % 2u }) // true
println(values.allEqualBy { it }) // false
//sampleEnd
}