我对"Scala编程"一书中的理解是,以下应该返回一个Array[String]而不是它返回一个Iterator[String].我错过了什么?
val data = for (line <- Source.fromFile("data.csv").getLines()) yield line
Run Code Online (Sandbox Code Playgroud)
我正在使用Scala 2.9.
提前致谢.
我无法import b._理解为什么在下面的代码中,拉入的import()implicit def必须出现在位置1和位置2才能工作.
package a {
abstract class Base {}
}
package b {
import a._
class Derived(i: Int) extends Base {}
object b {
implicit def i2d(i: Int): Derived = new Derived(i)
}
}
import a._
// position 1
import b._
object test extends App {
// position 2
import b._
def doIt(base: Base) {
println("works")
}
doIt(1)
}
Run Code Online (Sandbox Code Playgroud) scala ×2