contentEquals
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.4Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.3Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.3Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
Since Kotlin
1.3Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.3Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.3Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
The arrays are also considered structurally equal if both are null
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. For floating point numbers, this means NaN
is equal to itself and -0.0
is not equal to 0.0
.
If the arrays contain nested arrays, use contentDeepEquals to recursively compare their elements.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = arrayOf("apples", "oranges", "lime")
// the same size and equal elements
println(array.contentEquals(arrayOf("apples", "oranges", "lime"))) // true
// different size
println(array.contentEquals(arrayOf("apples", "oranges"))) // false
// the elements at index 1 are not equal
println(array.contentEquals(arrayOf("apples", "lime", "oranges"))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = intArrayOf(1, 2, 3)
// the same size and equal elements
println(array.contentEquals(intArrayOf(1, 2, 3))) // true
// different size
println(array.contentEquals(intArrayOf(1, 2))) // false
// the elements at index 1 are not equal
println(array.contentEquals(intArrayOf(1, 3, 2))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal. Elements are compared for equality using the equals function. This means NaN
is equal to itself and -0.0
is not equal to 0.0
.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = doubleArrayOf(1.0, Double.NaN, 0.0)
// the same size and equal elements, NaN is equal to NaN
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, 0.0))) // true
// different size
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN))) // false
// the elements at index 2 are not equal, 0.0 is not equal to -0.0
println(array.contentEquals(doubleArrayOf(1.0, Double.NaN, -0.0))) // false
// the elements at index 1 are not equal
println(array.contentEquals(doubleArrayOf(1.0, 0.0, Double.NaN))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = booleanArrayOf(true, false, true)
// the same size and equal elements
println(array.contentEquals(booleanArrayOf(true, false, true))) // true
// different size
println(array.contentEquals(booleanArrayOf(true, false))) // false
// the elements at index 1 are not equal
println(array.contentEquals(booleanArrayOf(true, true, false))) // false
//sampleEnd
}
Deprecated
Hidden since 1.4
Use Kotlin compiler 1.4 to avoid deprecation warning.
Checks if the two specified arrays are structurally equal to one another.
Two arrays are considered structurally equal if they have the same size, and elements at corresponding indices are equal.
Since Kotlin
1.8Return
true
if the two arrays are structurally equal, false
otherwise.
Parameters
the array to compare with this array.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val array = charArrayOf('a', 'b', 'c')
// the same size and equal elements
println(array.contentEquals(charArrayOf('a', 'b', 'c'))) // true
// different size
println(array.contentEquals(charArrayOf('a', 'b'))) // false
// the elements at index 1 are not equal
println(array.contentEquals(charArrayOf('a', 'c', 'b'))) // false
//sampleEnd
}