overloading + and += operators for “Number Classes”

前端 未结 4 829
野性不改
野性不改 2021-02-08 14:45

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 15:20

    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!

提交回复
热议问题