equals

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

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

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   assertTrue('a'.equals('a', false))
assertFalse('a'.equals('A', false))
assertTrue('a'.equals('A', true)) 
   //sampleEnd
}

Parameters

ignoreCase

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

Two characters are considered the same ignoring case if at least one of the following is true:

  • The two characters are the same (as compared by the == operator)

  • Applying the method uppercaseChar to each character produces the same result

  • Applying the method lowercaseChar to each character produces the same result


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

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

Parameters

ignoreCase

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

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

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

Parameters

ignoreCase

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

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

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

Parameters

ignoreCase

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