Reputation: 1
type mismatch
found : ((A, (Long, Array[String], Int))) => A
required: (A, (Long, Array[String], Int)) => A
I don't understand this error I am trying to fold over a sequence where A is the state type. Why has it 'found' a nested tuple where I have provided something like:
xs.foldLeft(zeroSt) {case (st,(a,b,c)) => st}
Upvotes: 0
Views: 77
Reputation: 48410
There is a syntax error where accumulator parameter of foldLeft
is missing
xs.foldLeft(zeroSt) { case (acc, (st, (a, b, c))) => // accumulate in acc }
^
|
this was missing
In other words, B
was specified incorrectly in the signature of foldLeft
def foldLeft[B](z: B)(op: (B, A) => B): B
^
|
this was incorrect
As a side note, I use the following mnemonic to remember where the accumulator fits:
Upvotes: 2