allEqual
Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(arrayOf<String>().allEqual()) // true
println(arrayOf("apple").allEqual()) // true
val sameValues = arrayOf("apple", "apple", "apple")
println(sameValues.allEqual()) // true
val mixedValues = arrayOf("apple", "apple", "orange")
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(byteArrayOf().allEqual()) // true
println(byteArrayOf(1).allEqual()) // true
val sameValues = byteArrayOf(1, 1, 1)
println(sameValues.allEqual()) // true
val mixedValues = byteArrayOf(1, 1, 2)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(shortArrayOf().allEqual()) // true
println(shortArrayOf(1).allEqual()) // true
val sameValues = shortArrayOf(1, 1, 1)
println(sameValues.allEqual()) // true
val mixedValues = shortArrayOf(1, 1, 2)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(intArrayOf().allEqual()) // true
println(intArrayOf(1).allEqual()) // true
val sameValues = intArrayOf(1, 1, 1)
println(sameValues.allEqual()) // true
val mixedValues = intArrayOf(1, 1, 2)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(longArrayOf().allEqual()) // true
println(longArrayOf(1L).allEqual()) // true
val sameValues = longArrayOf(1L, 1L, 1L)
println(sameValues.allEqual()) // true
val mixedValues = longArrayOf(1L, 1L, 2L)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using equality semantics consistent with Float.equals, and all elements are considered equal if the first element equals every subsequent element.
NaN is considered equal to NaN, and -0.0 is considered not equal to 0.0, consistent with Float.equals.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(floatArrayOf().allEqual()) // true
println(floatArrayOf(1.0f).allEqual()) // true
val sameValues = floatArrayOf(1.0f, 1.0f, 1.0f)
println(sameValues.allEqual()) // true
val mixedValues = floatArrayOf(1.0f, 1.0f, 2.0f)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using equality semantics consistent with Double.equals, and all elements are considered equal if the first element equals every subsequent element.
NaN is considered equal to NaN, and -0.0 is considered not equal to 0.0, consistent with Double.equals.
Since Kotlin
2.4Samples
import kotlin.math.abs
fun main() {
//sampleStart
println(doubleArrayOf().allEqual()) // true
println(doubleArrayOf(1.0).allEqual()) // true
val sameValues = doubleArrayOf(1.0, 1.0, 1.0)
println(sameValues.allEqual()) // true
val mixedValues = doubleArrayOf(1.0, 1.0, 2.0)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(booleanArrayOf().allEqual()) // true
println(booleanArrayOf(true).allEqual()) // true
val sameValues = booleanArrayOf(true, true, true)
println(sameValues.allEqual()) // true
val mixedValues = booleanArrayOf(true, true, false)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(charArrayOf().allEqual()) // true
println(charArrayOf('a').allEqual()) // true
val sameValues = charArrayOf('a', 'a', 'a')
println(sameValues.allEqual()) // true
val mixedValues = charArrayOf('a', 'a', 'b')
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the collection are equal to each other.
Returns true for an empty collection.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
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.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(listOf<String>().allEqual()) // true
println(listOf("apple").allEqual()) // true
val sameValues = listOf("apple", "apple", "apple")
println(sameValues.allEqual()) // true
val mixedValues = listOf("apple", "apple", "orange")
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(uintArrayOf().allEqual()) // true
println(uintArrayOf(1u).allEqual()) // true
val sameValues = uintArrayOf(1u, 1u, 1u)
println(sameValues.allEqual()) // true
val mixedValues = uintArrayOf(1u, 1u, 2u)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ulongArrayOf().allEqual()) // true
println(ulongArrayOf(1uL).allEqual()) // true
val sameValues = ulongArrayOf(1uL, 1uL, 1uL)
println(sameValues.allEqual()) // true
val mixedValues = ulongArrayOf(1uL, 1uL, 2uL)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ubyteArrayOf().allEqual()) // true
println(ubyteArrayOf(1u).allEqual()) // true
val sameValues = ubyteArrayOf(1u, 1u, 1u)
println(sameValues.allEqual()) // true
val mixedValues = ubyteArrayOf(1u, 1u, 2u)
println(mixedValues.allEqual()) // false
//sampleEnd
}Returns true if all elements in the array are equal to each other.
Returns true for an empty array.
The elements are compared sequentially using structural equality (==), and all elements are considered equal if the first element equals every subsequent element.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(ushortArrayOf().allEqual()) // true
println(ushortArrayOf(1u).allEqual()) // true
val sameValues = ushortArrayOf(1u, 1u, 1u)
println(sameValues.allEqual()) // true
val mixedValues = ushortArrayOf(1u, 1u, 2u)
println(mixedValues.allEqual()) // false
//sampleEnd
}