Strange type error
Toby <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
Dear Scala Team,
See below for a simple example that uses placeholder syntax, but fails to
compile. Essentially, execute accepts a ternary Double operator. In the
first example, where the function literal is _ + _ * _ the compile accepts
this, but with additional brackets to change precedence, (_ + _) * _ fails.
I'm sure there is a straightforward explanation for this, but I am
currently at a lost as to what it is. Any insights would be much
appreciated.
Thanks,
Tobias Grasl
object TestTernaryOp {
def execute(fn : (Double, Double, Double) => Double) = {
fn(1,2,3)
}
def main( args : Array[String]) = {
// Compiles fine
println(execute( _ + _ * _ ))
// Does not compile - type inference error
println(execute( (_ + _) * _ ))
}
}
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.