연산자 규칙 중 하나와 일치하지만 operator 키워드가 없는 함수를 보고합니다.

operator 제어자를 추가하면 함수 컨슈머가 관용적 Kotlin 코드를 사용할 수 있게 할 수 있습니다.

예:


  class Complex(val real: Double, val imaginary: Double) {
      fun plus(other: Complex) =
          Complex(real + other.real, imaginary + other.imaginary)
  }

  fun usage(a: Complex, b: Complex) {
      a.plus(b)
  }

빠른 수정에서는 operator 제어자 키워드를 추가합니다.


  class Complex(val real: Double, val imaginary: Double) {
      operator fun plus(other: Complex) =
          Complex(real + other.real, imaginary + other.imaginary)
  }

  fun usage(a: Complex, b: Complex) {
      a + b
  }