- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Second parameter list & Overloading, Bug or „normal“ behaviour?
Thu, 2008-12-18, 13:41
class Over {
def fun(i: Int): Double = i
def fun(i: Int)(fn:Int=>Double): Double = fn(i)
}
object OverTester {
def main(args : Array[String]): Unit = {
val over = new Over
over.fun(5) // <- error
}
}
Compiler Error:
ambiguous reference to overloaded definition,
both method fun in class Over of type (Int)((Int) => Double)Double
and method fun in class Over of type (Int)Double
match argument types (Int) and expected result type Unit
But
class Over {
def fun(i: Int): Double = i
def fun(i: Int, fn:Int=>Double): Double = fn(i)
}
is OK?
Toivo
BTW, your email address doesn't seem to work ...
On Thu, Dec 18, 2008 at 7:36 AM, toivo <tom.tad@mail.ee> wrote: