报告可以转换为字符串模板的字符串串联。

通常应该使用字符串模板,因为这样更容易读取代码。

示例:


  fun example() {
      val capitals = mapOf("France" to "Paris", "Spain" to "Madrid")
      for ((country, capital) in capitals) {
          print(capital + " is a capital of " + country)
      }
  }

应用修复后:


  fun example() {
      val capitals = mapOf("France" to "Paris", "Spain" to "Madrid")
      for ((country, capital) in capitals) {
          print("$capital is a capital of $country")
      }
  }