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 a Ready containing the result of
applying pf
to this Pot's contained
value, if this pot is
nonempty and pf
is defined for that value.
Returns a Ready containing the result of
applying pf
to this Pot's contained
value, if this pot is
nonempty and pf
is defined for that value.
Returns Empty otherwise.
the partial function.
the result of applying pf
to this Pot's
value (if possible), or Empty.
// Returns Ready(HTTP) because the partial function covers the case. Ready("http") collect {case "http" => "HTTP"} // Returns Empty because the partial function doesn't cover the case. Ready("ftp") collect {case "http" => "HTTP"} // Returns Empty because Empty is passed to the collect method. Empty collect {case value => value}
Tests whether the pot contains a given value as an element.
Tests whether the pot contains a given value as an element.
the element to test.
true
if the pot has an element that is equal (as
determined by ==
) to elem
, false
otherwise.
// Returns true because Ready instance contains string "something" which equals "something". Ready("something") contains "something" // Returns false because "something" != "anything". Ready("something") contains "anything" // Returns false when method called on Empty. Empty contains "anything"
Returns true if this pot is nonempty and the predicate $p returns true when applied to this Pot's value.
Returns true if this pot is nonempty and the predicate $p returns true when applied to this Pot's value. Otherwise, returns false.
the predicate to test
Returns this Pot if it is nonempty and applying the predicate $p to this Pot's value returns true.
Returns this Pot if it is nonempty and applying the predicate $p to this Pot's value returns true. Otherwise, return Empty.
the predicate used for testing.
Returns this Pot if it is nonempty and applying the predicate $p to this Pot's value returns false.
Returns this Pot if it is nonempty and applying the predicate $p to this Pot's value returns false. Otherwise, return Empty.
the predicate used for testing.
Returns the result of applying $f to this Pot's value if this Pot is nonempty.
Returns the result of applying $f to this Pot's value if
this Pot is nonempty.
Returns current Pot if this Pot does not have a value.
Slightly different from map
in that $f is expected to
return a pot (which could be Empty).
the function to apply
foreach
map
Returns the result of applying $f to this Pot's value if the Pot is nonempty.
Returns the result of applying $f to this Pot's
value if the Pot is nonempty. Otherwise, evaluates
expression ifEmpty
.
the expression to evaluate if empty.
the function to apply if nonempty.
This is equivalent to Pot map f getOrElse ifEmpty
.
Returns true if this pot is empty or the predicate $p returns true when applied to this Pot's value.
Returns true if this pot is empty or the predicate $p returns true when applied to this Pot's value.
the predicate to test
Apply the given procedure $f to the pot's value, if it is nonempty.
Apply the given procedure $f to the pot's value, if it is nonempty. Otherwise, do nothing.
the procedure to apply.
flatMap
map
Returns a singleton iterator returning the Pot's value if it is nonempty, or an empty iterator if the pot is empty.
Returns a singleton iterator returning the Pot's value if it is nonempty, or an empty iterator if the pot is empty.
Returns a Ready containing the result of applying $f to this Pot's value if this Pot is nonempty.
Returns a Ready containing the result of applying $f to this Pot's value if this Pot is nonempty. Otherwise return current Pot.
the function to apply
This is similar to flatMap
except here,
$f does not need to wrap its result in a pot.
foreach
flatMap
Returns false if the pot is Empty, true otherwise.
Returns false if the pot is Empty, true otherwise.
Implemented here to avoid the implicit conversion to Iterable.
Returns this Pot if it is nonempty,
otherwise return the result of evaluating alternative
.
Returns this Pot if it is nonempty,
otherwise return the result of evaluating alternative
.
the alternative expression.
Applies the given function f
if this is a Failure
, otherwise returns this if this is a Success
.
Applies the given function f
if this is a Failure
, otherwise returns this if this is a Success
.
This is like map for the exception.
Applies the given function f
if this is a Failure
, otherwise returns this if this is a Success
.
Applies the given function f
if this is a Failure
, otherwise returns this if this is a Success
.
This is like flatMap
for the exception.
Returns a scala.util.Right containing the given
argument right
if this is empty, or
a scala.util.Left containing this Pot's value
if this Pot is nonempty.
Returns a scala.util.Right containing the given
argument right
if this is empty, or
a scala.util.Left containing this Pot's value
if this Pot is nonempty.
the expression to evaluate and return if this is empty
toRight
Returns a singleton list containing the Pot's value if it is nonempty, or the empty list if the Pot is empty.
Returns a singleton list containing the Pot's value if it is nonempty, or the empty list if the Pot is empty.
Returns None
if this is empty or a Some
containing the value otherwise.
Returns None
if this is empty or a Some
containing the value otherwise.
Returns a scala.util.Left containing the given
argument left
if this Pot is empty, or
a scala.util.Right containing this Pot's value if
this is nonempty.
Returns a scala.util.Left containing the given
argument left
if this Pot is empty, or
a scala.util.Right containing this Pot's value if
this is nonempty.
the expression to evaluate and return if this is empty
toLeft
Returns Failure
if this has failed or a Success
containing the value otherwise.
Returns Failure
if this has failed or a Success
containing the value otherwise.
Necessary to keep Pot from being implicitly converted to
scala.collection.Iterable in for
comprehensions.
Necessary to keep Pot from being implicitly converted to
scala.collection.Iterable in for
comprehensions.