scala.Option

class Option

sealed abstract class Option[+ A]

 extends Product


This class represents optional values. Instances of Option are either instances of case class Some or it is case object None.
author
- Matthias Zenger
- Martin Odersky
version
- 1.1, 16/01/2007


Companion: Option

Source: Option.scala(31)

Direct Known Subclasses

None, Some,

 Constructors

def this

 Fields

elements def elements
An singleton iterator returning the option's value if it is nonempty or the empty iterator if the option is empty
Iterator[A]
get abstract def get
get the value of this option [details]
@requires that the option is nonEmpty.
throws
Predef.NoSuchElementException - if the option is empty.
A
isDefined def isDefined
True if the option is a Some( [details]
..) false otherwise.
Boolean
isEmpty abstract def isEmpty
True if the option is the None value, false otherwise
Boolean
productArity abstract def productArity
return k for a product A(x_1, [details]
..,x_k)
Int Product
productPrefix def productPrefix
By default the empty string [details]
Implementations may override this method in order to prepend a string prefix to the result of the toString methods.
String Product
toList def toList
A singleton list containing the option's value if it is nonempty or the empty list if the option is empty
List[A]

 Methods

!= final def !=(arg0 : Any) Boolean Any
!= final def !=(arg0 : Object) Boolean AnyRef
== final def ==(arg0 : Object) Boolean AnyRef
== final def ==(arg0 : Any) Boolean Any
asInstanceOf final def asInstanceOf[T0] T0 Any
clone protected def clone Object AnyRef
eq final def eq(arg0 : Object) Boolean AnyRef
equals def equals(arg0 : Any) Boolean AnyRef
filter def filter(p : (A) => Boolean)
If the option is nonempty and the given predicate p yields false on its value, return None [details]
Otherwise return the option value itself.
param
p - the predicate used for testing.
Option[A]
finalize protected def finalize Unit AnyRef
flatMap def flatMap[B](f : (A) => Option[B])
If the option is nonempty, return a function applied to its value [details]
Otherwise return None.
param
f - the function to apply
Option[B]
foreach def foreach(f : (A) => Unit)
Apply the given procedure f to the option's value, if it is nonempty [details]
Do nothing if it is empty.
param
f - the procedure to apply.
Unit
get def get[B >: A](default : B)
[details]
deprecated
- ; use getOrElse instead
B
getClass final def getClass Class[Any] AnyRef
getOrElse def getOrElse[B >: A](default : => B)
If the option is nonempty return its value, otherwise return the result of evaluating a default expression [details]
param
default - the default expression.
B
hashCode def hashCode Int AnyRef
isInstanceOf final def isInstanceOf[T0] Boolean Any
map def map[B](f : (A) => B)
If the option is nonempty, return a function applied to its value, wrapped in a Some i [details]
e. Some(f(this.get)). Otherwise return None.
param
f - the function to apply
Option[B]
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
orElse def orElse[B >: A](alternative : => Option[B])
If the option is nonempty return it, otherwise return the result of evaluating an alternative expression [details]
param
alternative - the alternative expression.
Option[B]
productElement abstract def productElement(n : Int)
for a product A(x_1, [details]
..,x_k), returns x_(n+1) for 0 <= n < k
param
n - the index of the element to return
return
- The element n elements after the first element
Any Product
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
toLeft def toLeft[X](right : => X)
An Either that is a Right with the given argument right if this is empty, or a Left if this is nonempty with the option's value
Either[A, X] with Product
toRight def toRight[X](left : => X)
An Either that is a Left with the given argument left if this is empty, or a Right if this is nonempty with the option's value
Either[X, A] with Product
toString def toString String AnyRef
wait final def wait Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
Copyright (c) 2008. All Rights Reserved.