报告可由 equals(..., ignoreCase = true) 替换的不区分大小写的比较。

通过使用 equals(),无需分配具有 toLowerCase()toUpperCase() 的额外字符串即可比较字符串。

快速修复会将使用 toLowerCase()toUpperCase() 的不区分大小写的比较替换为 equals(..., ignoreCase = true)

注意:可能会更改某些区域设置的语义。

示例:


  fun main() {
      val a = "KoTliN"
      val b = "KOTLIN"
      println(a.toLowerCase() == b.toLowerCase())
  }

在应用快速修复后:


  fun main() {
      val a = "KoTliN"
      val b = "KOTLIN"
      println(a.equals(b, ignoreCase = true))
  }