equals
fun
String
?
.
equals
(
other
:
String
?
,
ignoreCase
:
Boolean
=
false
)
:
Boolean
(Common source) (JVM source) (JS source) (Native 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.
Parameters
ignoreCase
-
true
to ignore character case when comparing strings. By default
false
.
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
.