The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Mark Elston (133) [Avatar] Offline
I have a little trouble with the example at the bottom of page 33 in the book. You say the foldLeft function takes two parameters but you call it as follows:

x.foldLeft(0) { (a, b) => a + b }

I am guessing that this is equivalent to:

x.foldLeft(0, { (a, b) => a + b } )

which is what I expect when I read that the foldLeft function takes 2 parameters. However, when I try to use the second form in the scala console I get an error message that I don't really understand except that the function call has too many parameters.

Perhaps this is a syntax thing that I am not getting just yet. I looked on for anything I could find relating to function invocation but couldn't figure out what is going on here.

Can someone explain this syntax for me?