ClassSome[A] represents existing values of typeA.
We need a whole WithFilter class to honor the "doesn't create a new collection" contract even though it seems unlikely to matter much in a collection with max size 1.
We need a whole WithFilter class to honor the "doesn't create a new collection" contract even though it seems unlikely to matter much in a collection with max size 1.
Returns the option's value.
Returns the option's value.
This is equivalent to:
option match { case Some(x) => x case None => throw new Exception}NoSuchElementExceptionif the option is empty.
The option must be nonempty.
Returns ascala.Some containing the result of applyingpf to thisscala.Option's contained value,if this option is nonemptyandpf is defined for that value.
Returns ascala.Some containing the result of applyingpf to thisscala.Option's contained value,if this option is nonemptyandpf is defined for that value. ReturnsNone otherwise.
the partial function.
the result of applyingpf to thisscala.Option's value (if possible), orNone.
// Returns Some(HTTP) because the partial function covers the case.Some("http") collect {case "http" => "HTTP"}// Returns None because the partial function doesn't cover the case.Some("ftp") collect {case "http" => "HTTP"}// Returns None because the option is empty. There is no value to pass to the partial function.None collect {case value => value}Tests whether the option contains a given value as an element.
Tests whether the option contains a given value as an element.
This is equivalent to:
option match { case Some(x) => x == elem case None => false}the element to test.
true if the option has an element that is equal (as determined by==) toelem,false otherwise.
// Returns true because Some instance contains string "something" which equals "something".Some("something") contains "something"// Returns false because "something" != "anything".Some("something") contains "anything"// Returns false when method called on None.None contains "anything"Returns true if this option is nonemptyand the predicatep returns true when applied to thisscala.Option's value.
Returns true if this option is nonemptyand the predicatep returns true when applied to thisscala.Option's value. Otherwise, returns false.
This is equivalent to:
option match { case Some(x) => p(x) case None => false}the predicate to test
Returns thisscala.Option if it is nonemptyand applying the predicatep to thisscala.Option's value returns true.
Returns thisscala.Option if it is nonemptyand applying the predicatep to thisscala.Option's value returns true. Otherwise, returnNone.
This is equivalent to:
option match { case Some(x) if p(x) => Some(x) case _ => None}the predicate used for testing.
Returns thisscala.Option if it is nonemptyand applying the predicatep to thisscala.Option's value returns false.
Returns thisscala.Option if it is nonemptyand applying the predicatep to thisscala.Option's value returns false. Otherwise, returnNone.
This is equivalent to:
option match { case Some(x) if !p(x) => Some(x) case _ => None}the predicate used for testing.
Returns the result of applyingf to thisscala.Option's value if thisscala.Option is nonempty.
Returns the result of applyingf to thisscala.Option's value if thisscala.Option is nonempty. ReturnsNone if thisscala.Option is empty. Slightly different frommap in thatf is expected to return anscala.Option (which could beNone).
This is equivalent to:
option match { case Some(x) => f(x) case None => None}the function to apply
map
foreach
Returns the nestedscala.Option value if it is nonempty.
Returns the nestedscala.Option value if it is nonempty. Otherwise, returnNone.
This is equivalent to:
option match { case Some(Some(b)) => Some(b) case _ => None}an implicit conversion that asserts that the value is also anscala.Option.
flatMap
Some(Some("something")).flattenReturns the result of applyingf to thisscala.Option's value if thescala.Option is nonempty.
Returns the result of applyingf to thisscala.Option's value if thescala.Option is nonempty. Otherwise, evaluates expressionifEmpty.
This is equivalent to:
option match { case Some(x) => f(x) case None => ifEmpty}This is also equivalent to:
option map f getOrElse ifEmptythe function to apply if nonempty.
the expression to evaluate if empty.
Returns true if this option is emptyor the predicatep returns true when applied to thisscala.Option's value.
Returns true if this option is emptyor the predicatep returns true when applied to thisscala.Option's value.
This is equivalent to:
option match { case Some(x) => p(x) case None => true}the predicate to test
Apply the given proceduref to the option's value, if it is nonempty.
Apply the given proceduref to the option's value, if it is nonempty. Otherwise, do nothing.
This is equivalent to:
option match { case Some(x) => f(x) case None => ()}the procedure to apply.
map
flatMap
Returns the option's value if the option is nonempty, otherwise return the result of evaluatingdefault.
Returns the option's value if the option is nonempty, otherwise return the result of evaluatingdefault.
This is equivalent to:
option match { case Some(x) => x case None => default}the default expression.
Returns true if the option is an instance ofscala.Some, false otherwise.
Returns true if the option is an instance ofscala.Some, false otherwise.
This is equivalent to:
option match { case Some(_) => true case None => false}Returns true if the option isNone, false otherwise.
Returns true if the option isNone, false otherwise.
This is equivalent to:
option match { case Some(_) => false case None => true}Returns a singleton iterator returning thescala.Option's value if it is nonempty, or an empty iterator if the option is empty.
Returns a singleton iterator returning thescala.Option's value if it is nonempty, or an empty iterator if the option is empty.
The number of elements in this option, if it can be cheaply computed, -1 otherwise.
The number of elements in this option, if it can be cheaply computed, -1 otherwise. Cheaply usually means: Not requiring a collection traversal.
Returns ascala.Some containing the result of applyingf to thisscala.Option's value if thisscala.Option is nonempty.
Returns ascala.Some containing the result of applyingf to thisscala.Option's value if thisscala.Option is nonempty. Otherwise returnNone.
This is equivalent to:
option match { case Some(x) => Some(f(x)) case None => None}the function to apply
flatMap
foreach
This is similar toflatMap except here,f does not need to wrap its result in anscala.Option.
Returns false if the option isNone, true otherwise.
Returns false if the option isNone, true otherwise.
This is equivalent to:
option match { case Some(_) => true case None => false}Implemented here to avoid the implicit conversion to Iterable.
Returns thisscala.Option if it is nonempty, otherwise return the result of evaluatingalternative.
Returns thisscala.Option if it is nonempty, otherwise return the result of evaluatingalternative.
This is equivalent to:
option match { case Some(x) => Some(x) case None => alternative}the alternative expression.
Returns the option's value if it is nonempty, ornull if it is empty.
Returns the option's value if it is nonempty, ornull if it is empty.
Although the use of null is discouraged, code written to usescala.Option must often interface with code that expects and returns nulls.
This is equivalent to:
option match { case Some(x) => x case None => null}val initialText: Option[String] = getInitialTextval textField = new JComponent(initialText.orNull,20)An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
An iterator over all the elements of this product.
An iterator over all the elements of this product.
in the default implementation, anIterator[Any]
Returns ascala.collection.Stepper for the elements of this collection.
Returns ascala.collection.Stepper for the elements of this collection.
The Stepper enables creating a Java stream to operate on the collection, seescala.jdk.StreamConverters. For collections holding primitive values, the Stepper can be used as an iterator which doesn't box the elements.
The implicitscala.collection.StepperShape parameter defines the resulting Stepper type according to the element type of this collection.
For collections ofInt,Short,Byte orChar, anscala.collection.IntStepper is returned
For collections ofDouble orFloat, ascala.collection.DoubleStepper is returned
For collections ofLong ascala.collection.LongStepper is returned
For any other element type, anscala.collection.AnyStepper is returned
Note that this method is overridden in subclasses and the return type is refined toS with EfficientSplit, for examplescala.collection.IndexedSeqOps.stepper. For Steppers marked withscala.collection.Stepper.EfficientSplit, the converters inscala.jdk.StreamConverters allow creating parallel streams, whereas bare Steppers can be converted only to sequential streams.
Returns ascala.util.Right containing the given argumentright if this is empty, or ascala.util.Left containing thisscala.Option's value if thisscala.Option is nonempty.
Returns ascala.util.Right containing the given argumentright if this is empty, or ascala.util.Left containing thisscala.Option's value if thisscala.Option is nonempty.
This is equivalent to:
option match { case Some(x) => Left(x) case None => Right(right)}the expression to evaluate and return if this is empty
toRight
Returns a singleton list containing thescala.Option's value if it is nonempty, or the empty list if thescala.Option is empty.
Returns a singleton list containing thescala.Option's value if it is nonempty, or the empty list if thescala.Option is empty.
This is equivalent to:
option match { case Some(x) => List(x) case None => Nil}Returns ascala.util.Left containing the given argumentleft if thisscala.Option is empty, or ascala.util.Right containing thisscala.Option's value if this is nonempty.
Returns ascala.util.Left containing the given argumentleft if thisscala.Option is empty, or ascala.util.Right containing thisscala.Option's value if this is nonempty.
This is equivalent to:
option match { case Some(x) => Right(x) case None => Left(left)}the expression to evaluate and return if this is empty
toLeft
Converts an Option of a pair into an Option of the first element and an Option of the second element.
Converts an Option of a pair into an Option of the first element and an Option of the second element.
This is equivalent to:
option match { case Some((x, y)) => (Some(x), Some(y)) case _ => (None, None)}the type of the first half of the element pair
the type of the second half of the element pair
an implicit conversion which asserts that the element type of this Option is a pair.
a pair of Options, containing, respectively, the first and second half of the element pair of this Option.
Converts an Option of a triple into three Options, one containing the element from each position of the triple.
Converts an Option of a triple into three Options, one containing the element from each position of the triple.
This is equivalent to:
option match { case Some((x, y, z)) => (Some(x), Some(y), Some(z)) case _ => (None, None, None)}the type of the first of three elements in the triple
the type of the second of three elements in the triple
the type of the third of three elements in the triple
an implicit conversion which asserts that the element type of this Option is a triple.
a triple of Options, containing, respectively, the first, second, and third elements from the element triple of this Option.
Necessary to keepscala.Option from being implicitly converted toscala.collection.Iterable infor comprehensions.
Necessary to keepscala.Option from being implicitly converted toscala.collection.Iterable infor comprehensions.
Returns ascala.Some formed from this option and another option by combining the corresponding elements in a pair.
Returns ascala.Some formed from this option and another option by combining the corresponding elements in a pair. If either of the two options is empty,None is returned.
This is equivalent to:
(option1, option2) match { case (Some(x), Some(y)) => Some((x, y)) case _ => None}the options which is going to be zipped
// Returns Some(("foo", "bar")) because both options are nonempty.Some("foo") zip Some("bar")// Returns None because `that` option is empty.Some("foo") zip None// Returns None because `this` option is empty.None zip Some("bar")