相关疑难解决方法(0)

功能尝试和捕获与Scala

是否有更多的自动方式在Scala中打开资源并将方法应用于此方法(直接从java转换),使用__CODE__但也包括finally等.

var is: FileInputStream = null
try {
  is = new FileInputStream(in)
  func(is)
} catch {
  case e: IOException =>
    println("Error: could not open file.")
    println("       -> " + e)
    exit(1)
} finally {
  if(is) is.close()
}
Run Code Online (Sandbox Code Playgroud)

functional-programming scala

21
推荐指数
3
解决办法
2万
查看次数

标签 统计

functional-programming ×1

scala ×1