我看到了这个话题:
What are the biggest differences between Scala 2.8 and Scala 2.7?
它似乎涵盖了一些更改,但似乎没有提到我遇到的第一个编译问题。有什么建议?
trait IterableLike 中的方法迭代器
类型 => Iterator[java.io.File] 是
未定义
trait IterableLike 中的方法迭代器
类型 => Iterator[V] 未定义
IterableLike 类型 =>
迭代器[java.io.File];方法
元素需要`override'修饰符
IterableLike 类型 => Iterator[V];
方法元素需要“覆盖”
修饰符
这是有问题的代码:
/**
* Filesystem walker.
* <p>
* Less magic version of: http://rosettacode.org/wiki/Walk_Directory_Tree#Scala
*/
object FsWalker {
/**
* Recursive iterator over all files (and directories) in given directory.
*/
def walk(f: File): Iterable[File] = new Iterable[File] {
def elements = {
if (f.isDirectory()) {
// recurse on our child files
f.listFiles.elements.flatMap(child => FsWalker.walk(child).elements)
} else {
// just return given file wrapped in Iterator
Seq(f).elements
}
}
}
}
最佳答案
前者elements
现在是 iterator
.
您应该使用 -Xmigration 进行编译,以获得有关如何将代码从 2.7 移植到 2.8 的有用提示。
关于scala - 将新的 Iterable{} 代码从 Scala 2.7.7 移植到 2.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3444748/