blob: a8055bf77dc9aa6651ccfea7f95197de91f08c0e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
Given the following code (which is broken):
class Mxml {
private def processChildren( children:Seq[Any] ):List[Mxml] = {
children.toList.flatMap ( e => {
e match {
case s:scala.collection.Traversable[_] => s case a => List(a)
}
})
}
}
I get the following error:
Mxml.scala:5: error: could not find implicit value for parameter bf:scala.collection.generic.BuilderFactory[Any,List[Mxml],Sequence[Any]].
children.flatMap ( e => {
I spent 4 hours failing before I figured out the problem. The return type was wrong. It should have been List[Any].
I have seen similar errors with map. My solution in the past has been to change it to a foldLeft because I have never been able to determine how to fix the problem until now.
|