Back to Intellij Community

StringReferentialEquality

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/StringReferentialEquality.html

2025.3-rc-2464 B
Original Source

Reports code that uses === or !== to compare strings.

These operators determine referential equality instead of comparing content. In most cases, strings should be compared using == or !=, which does a character-by-character comparison when the strings are different objects.

Example:

fun foo(s: String, t: String) {
    val b = t === s
  }

After the quick-fix is applied:

fun foo(s: String, t: String) {
    val b = t == s
  }