Plus not working in Scala interpreter?

The plus operator by itself is not a function it is a symbol and has no type. What you are looking for is the following.

The plus operator by itself is not a function it is a symbol and has no type. What you are looking for is the following val list = List(1,2,3) (list :\ 0)(_+_) The _+_ is shorthand for an anonymous function that takes two parameters and calls the + method on the first parameter passing in the second.

Thanks a lot! It works now. :) – astay13 Dec 1 '11 at 5:40.

Try this: (list :\ 0)(_ + _) You need to use the wildcards to show the Scala compiler that you want to call the "+" method on first of the arguments instead of using the Tuple2 as an argument to a function itself.

3 What Tuple2?... – Luigi Plinge Dec 1 '11 at 10:39 Sorry, I was incorrect. Rather the plus method defined above is a Function2 which has it's apply method called by the foldLeft. Meanwhile the + operator is defined on the Int class as a method, so we need to tell the Scala compiler which object we want to call the + method on – Aaron Dec 2 '11 at 1:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions