def + (that: Int): Rational = new Rational(numer * 1 + that * denom, denom)
implicit def intToRational(x: Int) = new Rational(x, 1)
override def toString() = numer+"/"+denom }
// test code val x = new Rational(1, 2) println(x)
val y = x + 1 println(y)
val z = 1 + x
But instead of getting the implicit conversion, I get a compiler error on the line above (saying that the overloaded method value + cannot be applied to (Rational).
Have I mistyped something? Do I have an error or is this a compiler error?