读书人

scala的Option部类

发布时间: 2013-02-24 17:58:56 作者: rapoo

scala的Option类型
var s = Some("abc") var t: Option[String] = None def chooseFile(): Option[File] = { ... }//比较嗦的方式chooseFile() match { case Some(f) => case None => }//比较土的方式if (t isDefined) println(t)if (t isEmpty) println("Nothing here!")//比较简单的方式val w = t.getOrElse("Nothing here!")

?

?

读书人网 >编程

热点推荐