You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classVector (valx:Double, valy:Double, valz:Double) {
def*(f: Double) =newVector(x * f, y * f, z * f)
def+(v: Vector) =newVector(x + v.x, y + v.y, z + v.z)
}
objectScope1 {
definterpolate(t: Double, a: Double, b: Double):Double= a * (1.0- t) + b * t
}
objectScope2 {
definterpolate(t: Double, a: Vector, b: Vector):Vector= a * (1.0- t) + b * t
}
classExample {
importScope1._importScope2._defmain(args: Array[String]) {
valv= interpolate(0.3, 2.5, 4.5)
}
}
When I compile this with Scala 2.8.0.RC6, I get an unexpected error message:
Example.scala:21: error: reference to interpolate is ambiguous;
it is imported twice in the same scope by
import Scope2._
and import Scope1._
val v = interpolate(0.3, 2.5, 4.5)
^
one error found
Why does the compiler think the reference is ambiguous? The two interpolate methods have different signatures and it should be clear which one I want to apply. Note that if I put them both in class Example, without importing them, it works without a problem:
// No problemclassExample {
definterpolate(t: Double, a: Double, b: Double):Double= a * (1.0- t) + b * t
definterpolate(t: Double, a: Vector, b: Vector):Vector= a * (1.0- t) + b * t
defmain(args: Array[String]) {
valv= interpolate(0.3, 2.5, 4.5)
}
}
The text was updated successfully, but these errors were encountered:
I have the following code:
When I compile this with Scala 2.8.0.RC6, I get an unexpected error message:
Example.scala:21: error: reference to interpolate is ambiguous;
it is imported twice in the same scope by
import Scope2._
and import Scope1._
val v = interpolate(0.3, 2.5, 4.5)
^
one error found
Why does the compiler think the reference is ambiguous? The two interpolate methods have different signatures and it should be clear which one I want to apply. Note that if I put them both in class Example, without importing them, it works without a problem:
The text was updated successfully, but these errors were encountered: