equals

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun String?.equals(
    other: String?, 
    ignoreCase: Boolean = false
): Boolean

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.

Parameters

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

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun Char.equals(
    other: Char, 
    ignoreCase: Boolean = false
): Boolean

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.

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

fun main(args: Array<String>) {
//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
}

Parameters

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

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/equals.html