I keep getting this error:
[error] found : (scala.xml.NodeSeq, Int) => scala.xml.NodeSeq
[error] required: (scala.xml.NodeSeq, Int) => scala.collection.GenTraversableOnce[?]
[error] { answers.zipWithIndex.flatMap(answerElem) }
[error] ^
[error] one error found
answers is just a List[NodeSeq] and answerElem just checks the index and sets an attribute on an element. As you can see, its parameters are the right type, and NodeSeq says that it extends GenTraversableOnce.
Is there a hint I have to give it to help it compile?
Todd
Can you confirm if your function is of type
Function2[NodeSeq, Int, GenTraversableOnce[_]]orFunction1[(NodeSeq, Int), GenTraversableOnce[_]]? If it’s the former, that could be your problem, becausezipWithIndexproduces tuples. The answer would then be:I did an experiment with an un-tupled function and reproduced something like your problem, and fixed it with the above. Not the most helpful error message though…