scala-arm:Iterator [Int]类型的表达式不符合预期的ManagedResource [B_]类型

时间:2019-06-14 14:14:06

标签: scala scala-arm

此代码使用"com.jsuereth" %% "scala-arm" % "2.0"

import resource._
val lineLengths = for {
  source <- managed(scala.io.Source.fromFile("file.txt"))
  line <- source.getLines()
} yield line.length

编译失败并显示错误:

Expression of type Iterator[Int] doesn't conform to expected type ManagedResource[B_]

有什么主意吗?

0 个答案:

没有答案