小编dom*_*e89的帖子

Referring to "it" in the outer for loop

I have a question about accessing the it in the outer loop in kotlin. I am trying to see how many letters differ between two strings. I would like to know is there a way to access the outer for loop with it?

fun compute (stringOne: String, stringTwo: String): Int {
  var i = 0
  stringOne.toCharArray().forEach @loop{
    stringTwo.toCharArray().forEach {
      if (it@loop.equals(it))
        i++
    }
   }
  return i
}
Run Code Online (Sandbox Code Playgroud)

label loops kotlin

1
推荐指数
1
解决办法
28
查看次数

标签 统计

kotlin ×1

label ×1

loops ×1