equals

fun Char.equals(other: Char, ignoreCase: Boolean = false): Boolean(source)

Returns true if this character is equal to the other character, optionally ignoring character case.

Two characters are considered equal ignoring case if Char.uppercaseChar().lowercaseChar() on each character produces the same result.

Since Kotlin

1.0

Parameters

ignoreCase

true to ignore character case when comparing characters. By default false.

Samples

import java.util.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   println("'a'.equals('a', false) is ${'a'.equals('a', false)}") // true
println("'a'.equals('A', false) is ${'a'.equals('A', false)}") // false
println("'a'.equals('A', true) is ${'a'.equals('A', true)}") // true 
   //sampleEnd
}

expect fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean(source)

Returns true if this string is equal to other, optionally ignoring character case.

Two strings are considered to be equal if they have the same length and the same character at the same index. If ignoreCase is true, the result of Char.uppercaseChar().lowercaseChar() on each character is compared.

Since Kotlin

1.0

Parameters

ignoreCase

true to ignore character case when comparing strings. By default false.

actual fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean(source)

Returns true if this string is equal to other, optionally ignoring character case.

Two strings are considered to be equal if they have the same length and the same character at the same index. If ignoreCase is true, the result of Char.uppercaseChar().lowercaseChar() on each character is compared.

Since Kotlin

1.1

Parameters

ignoreCase

true to ignore character case when comparing strings. By default false.

actual fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean(source)

Returns true if this string is equal to other, optionally ignoring character case.

Two strings are considered to be equal if they have the same length and the same character at the same index. If ignoreCase is true, the result of Char.uppercaseChar().lowercaseChar() on each character is compared.

Since Kotlin

1.0

Parameters

ignoreCase

true to ignore character case when comparing strings. By default false.

actual fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean(source)

Returns true if this string is equal to other, optionally ignoring character case.

Two strings are considered to be equal if they have the same length and the same character at the same index. If ignoreCase is true, the result of Char.uppercaseChar().lowercaseChar() on each character is compared.

Since Kotlin

1.3

Parameters

ignoreCase

true to ignore character case when comparing strings. By default false.