scala: list.flatten: no implicit argument matching parameter type (Any) = > Iterable[Any] was found
问题 compiling this code in scala 2.7.6: def flatten1(l: List[Any]): List[Any] = l.flatten i get the error: no implicit argument matching parameter type (Any) = > Iterable[Any] was found why? 回答1: If you are expecting to be able to "flatten" List(1, 2, List(3,4), 5) into List(1, 2, 3, 4, 5) , then you need something like: implicit def any2iterable[A](a: A) : Iterable[A] = Some(a) Along with: val list: List[Iterable[Int]] = List(1, 2, List(3,4), 5) // providing type of list // causes implicit //