단순화할 수 있는 also 또는 apply 같은 범위 함수에 포함된 forEach 함수를 보고합니다.

forEach 호출을 onEach로 변환 빠른 수정을 사용해 코드를 자동으로 수정할 수 있습니다.

예:


  fun test(list: List<Int>) {
      val x = list.also { it.forEach { it + 4 } }.toString()
      val y = list.apply { forEach { println(it) } }
  }

빠른 수정을 적용한 후:


  fun test(list: List<Int>) {
      val x = list.onEach { it + 4 }.toString()
      val y = list.onEach { println(it) }
  }