contentEquals

expect infix fun ByteArray?.contentEquals(other: ByteArray?): Boolean(source)
expect infix fun ShortArray?.contentEquals(other: ShortArray?): Boolean(source)
expect infix fun IntArray?.contentEquals(other: IntArray?): Boolean(source)
expect infix fun LongArray?.contentEquals(other: LongArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

expect infix fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

expect infix fun FloatArray?.contentEquals(other: FloatArray?): Boolean(source)
expect infix fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

expect infix fun CharArray?.contentEquals(other: CharArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}
actual infix fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun ByteArray?.contentEquals(other: ByteArray?): Boolean(source)
actual infix fun ShortArray?.contentEquals(other: ShortArray?): Boolean(source)
actual infix fun IntArray?.contentEquals(other: IntArray?): Boolean(source)
actual infix fun LongArray?.contentEquals(other: LongArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun FloatArray?.contentEquals(other: FloatArray?): Boolean(source)
actual infix fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun CharArray?.contentEquals(other: CharArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}
actual infix inline fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix inline fun ByteArray?.contentEquals(other: ByteArray?): Boolean(source)
actual infix inline fun ShortArray?.contentEquals(other: ShortArray?): Boolean(source)
actual infix inline fun IntArray?.contentEquals(other: IntArray?): Boolean(source)
actual infix inline fun LongArray?.contentEquals(other: LongArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix inline fun FloatArray?.contentEquals(other: FloatArray?): Boolean(source)
actual infix inline fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix inline fun BooleanArray?.contentEquals(other: BooleanArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix inline fun CharArray?.contentEquals(other: CharArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}
actual infix fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun ByteArray?.contentEquals(other: ByteArray?): Boolean(source)
actual infix fun ShortArray?.contentEquals(other: ShortArray?): Boolean(source)
actual infix fun IntArray?.contentEquals(other: IntArray?): Boolean(source)
actual infix fun LongArray?.contentEquals(other: LongArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun FloatArray?.contentEquals(other: FloatArray?): Boolean(source)
actual infix fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun CharArray?.contentEquals(other: CharArray?): Boolean(source)

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.4

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean(source)

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.3

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.3

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.3

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.3

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.3

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}
actual infix fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun ByteArray?.contentEquals(other: ByteArray?): Boolean(source)
actual infix fun ShortArray?.contentEquals(other: ShortArray?): Boolean(source)
actual infix fun IntArray?.contentEquals(other: IntArray?): Boolean(source)
actual infix fun LongArray?.contentEquals(other: LongArray?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun FloatArray?.contentEquals(other: FloatArray?): Boolean(source)
actual infix fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun CharArray?.contentEquals(other: CharArray?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}
actual infix fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun ByteArray?.contentEquals(other: ByteArray?): Boolean(source)
actual infix fun ShortArray?.contentEquals(other: ShortArray?): Boolean(source)
actual infix fun IntArray?.contentEquals(other: IntArray?): Boolean(source)
actual infix fun LongArray?.contentEquals(other: LongArray?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun FloatArray?.contentEquals(other: FloatArray?): Boolean(source)
actual infix fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

actual infix fun CharArray?.contentEquals(other: CharArray?): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}

infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean(source)

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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.8

Return

true if the two arrays are structurally equal, false otherwise.

Parameters

other

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
}