00007 Scala Option Some Null
sealed abstract class Option[+A] extends Product with Serializable final case class Some[+A](@deprecatedName('x, "2.12.0") value: A) extends Option[A] {
def isEmpty = false
def get = value
@deprecated("Use .value instead.", "2.12.0") def x: A = value
}
/** This case object represents non-existent values.
*
* @author Martin Odersky
* @since 1.0
*/
@SerialVersionUID(5066590221178148012L) // value computed by serialver for 2.11.2, annotation added in 2.11.4
case object None extends Option[Nothing] {
def isEmpty = true
def get = throw new NoSuchElementException("None.get")
}Option和Some
Option和None
Option和模式匹配
最后更新于
这有帮助吗?