For example, I have defined a +* operator for weighted sum in the following wrapper class for Double:
class DoubleOps(val double: Double) {
def +*(other: DoubleOps, weight: Double): DoubleOps =
new DoubleOps(this.double + other.double * weight)
}
object DoubleOps {
implicit def DoubleToDoubleOps(double: Double) = new DoubleOps(double)
}
With this definition, I can have the following calculation:
var db: DoubleOps = 1.5
import DoubleOps._
db = db +* (2.0, 0.5)
println(db)
Is there a way I can calculate db using an assignment operator to get the result, like to define a +*=, so that I can use:
db +*= (2.0, 0.5)
Is this possible?