overloading + and += operators for “Number Classes”

前端 未结 4 766
别那么骄傲
别那么骄傲 2021-02-08 11:56

I want to create extension functions for classes that encapsulate simple Numbers. For example DoubleProperty. I encountered the problem, that I can\'t

4条回答
  •  温柔的废话
    2021-02-08 12:17

    You cannot overload both + and +=. Overload one of the them.

    When you write += in your code, theoretically both plus the plusAssign functions can be called (see figure 7.2). If this is the case, and both functions are defined and applicable, the compiler reports an error.

    I copied/pasted from Kotlin in Action book!

提交回复
热议问题