Returns a $some containing the result of
applying pf
to this $option's contained
value, if this option is
nonempty and pf
is defined for that value.
Returns a $some containing the result of
applying pf
to this $option's contained
value, if this option is
nonempty and pf
is defined for that value.
Returns $none otherwise.
the partial function.
the result of applying pf
to this $option's
value (if possible), or $none.
Returns true if this option is nonempty and the predicate $p returns true when applied to this $option's value.
Returns true if this option is nonempty and the predicate $p returns true when applied to this $option's value. Otherwise, returns false.
the predicate to test
Returns this $option if it is nonempty and applying the predicate $p to this $option's value returns true.
Returns this $option if it is nonempty and applying the predicate $p to this $option's value returns true. Otherwise, return $none.
the predicate used for testing.
Returns this $option if it is nonempty and applying the predicate $p to this $option's value returns false.
Returns this $option if it is nonempty and applying the predicate $p to this $option's value returns false. Otherwise, return $none.
the predicate used for testing.
Returns the result of applying $f to this $option's value if this $option is nonempty.
Returns the result of applying $f to this $option's value if
this $option is nonempty.
Returns $none if this $option is empty.
Slightly different from map
in that $f is expected to
return an $option (which could be $none).
the function to apply
foreach
map
Returns the result of applying $f to this $option's value if the $option is nonempty.
Returns the result of applying $f to this $option's
value if the $option is nonempty. Otherwise, evaluates
expression ifEmpty
.
the expression to evaluate if empty.
the function to apply if nonempty.
This is equivalent to $option map f getOrElse ifEmpty
.
Returns true if this option is empty or the predicate $p returns true when applied to this $option's value.
Returns true if this option is empty or the predicate $p returns true when applied to this $option's value.
the predicate to test
Apply the given procedure $f to the option's value, if it is nonempty.
Apply the given procedure $f to the option's value, if it is nonempty. Otherwise, do nothing.
the procedure to apply.
flatMap
map
Returns the option's value.
Returns the option's value.
if the option is empty.
The option must be nonEmpty.
Returns the option's value if the option is nonempty, otherwise
return the result of evaluating default
.
Returns the option's value if the option is nonempty, otherwise
return the result of evaluating default
.
the default expression.
Returns true if the option is not undefined
, false otherwise.
Returns true if the option is not undefined
, false otherwise.
Returns true if the option is undefined
, false otherwise.
Returns true if the option is undefined
, false otherwise.
Returns a singleton iterator returning the $option's value if it is nonempty, or an empty iterator if the option is empty.
Returns a singleton iterator returning the $option's value if it is nonempty, or an empty iterator if the option is empty.
Returns a $some containing the result of applying $f to this $option's value if this $option is nonempty.
Returns a $some containing the result of applying $f to this $option's value if this $option is nonempty. Otherwise return $none.
the function to apply
This is similar to flatMap
except here,
$f does not need to wrap its result in an $option.
foreach
flatMap
Returns false if the option is $none, true otherwise.
Returns false if the option is $none, true otherwise.
Implemented here to avoid the implicit conversion to Iterable.
Returns this $option if it is nonempty,
otherwise return the result of evaluating alternative
.
Returns this $option if it is nonempty,
otherwise return the result of evaluating alternative
.
the alternative expression.
Returns the option's value if it is nonempty,
or null
if it is empty.
Returns the option's value if it is nonempty,
or null
if it is empty.
Although the use of null is discouraged, code written to use
$option must often interface with code that expects and returns nulls.
val initalText: Option[String] = getInitialText val textField = new JComponent(initalText.orNull,20)
Returns a scala.util.Right containing the given
argument right
if this is empty, or
a scala.util.Left containing this $option's value
if this $option is nonempty.
Returns a scala.util.Right containing the given
argument right
if this is empty, or
a scala.util.Left containing this $option's value
if this $option is nonempty.
the expression to evaluate and return if this is empty
toRight
Returns a singleton list containing the $option's value if it is nonempty, or the empty list if the $option is empty.
Returns a singleton list containing the $option's value if it is nonempty, or the empty list if the $option is empty.
Returns a scala.util.Left containing the given
argument left
if this $option is empty, or
a scala.util.Right containing this $option's value if
this is nonempty.
Returns a scala.util.Left containing the given
argument left
if this $option is empty, or
a scala.util.Right containing this $option's value if
this is nonempty.
the expression to evaluate and return if this is empty
toLeft
Necessary to keep $option from being implicitly converted to
scala.collection.Iterable in for
comprehensions.
Necessary to keep $option from being implicitly converted to
scala.collection.Iterable in for
comprehensions.
(Since version 0.5.0)
Value of type A or the JS undefined value. In a type system with union types, this would really be
A | js.prim.Undefined
. Since Scala does not have union types, but this particular union is crucial to many interoperability scenarios, it is provided as this trait.An API similar to that of scala.Option is provided through the UndefOrOps implicit class, with the understanding that
undefined
is the None value.