This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Why is (sum _)(1, 2, 3) a type error

No replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

On Tue, Aug 26, 2008 at 04:34:02PM +0300, Pietu Pohjalainen wrote:
> Today, while programming scala for the public audience, I encountered
> this, which I don't clearly understand:
>
> scala> def sum(a: Int, b: Int, c: Int) = a + b + c
> sum: (Int,Int,Int)Int
>
> scala> (sum _)(1, 2, 3)
> :6: error: type mismatch;
> found : (Int,Int,Int)Int
> required: (?, ?, ?) => ?
> (sum _)(1, 2, 3)
>
> Why is it a type error?

Sorry to revive a 6 month old thread, but while the wheels of bugfixing may grind slowly, they do grind - as of
a few minutes ago this works.

scala> def sum(a: Int, b: Int, c: Int) = a + b + c
sum: (Int,Int,Int)Int

scala> (sum _)(1, 2, 3)
res0: Int = 6

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland