case class Success[A] extends Result[Nothing, A] with Product with Serializable
This class is used for when a parser succeeds, and contains its result.
- A
the type of expected success result.
- Source
- Result.scala
- Alphabetic
- By Inheritance
- Success
- Serializable
- Product
- Equals
- Result
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def contains[B >: A](elem: B): Boolean
Returns
true
if this result is aSuccess
and its value is equal toelem
(as determined by==
), returnsfalse
otherwise.Returns
true
if this result is aSuccess
and its value is equal toelem
(as determined by==
), returnsfalse
otherwise.- elem
the element to test.
- returns
true
if this is aSuccess
value equal toelem
.
- Definition Classes
- Result
- Since
1.7.0
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def exists(p: (A) => Boolean): Boolean
Returns
false
ifFailure
or returns the result of the application of the given predicate to theSuccess
value.Returns
false
ifFailure
or returns the result of the application of the given predicate to theSuccess
value.- Definition Classes
- Result
- Since
1.7.0
- def filterOrElse[Errʹ >: Nothing](p: (A) => Boolean, msg: => Errʹ): Result[Errʹ, A]
Returns
Success
with the existing value ofSuccess
if this is aSuccess
and the given predicatep
holds for the right value, orFailure(msg)
if this is aSuccess
and the given predicatep
does not hold for the right value, orFailure
with the existing value ofFailure
if this is aFailure
.Returns
Success
with the existing value ofSuccess
if this is aSuccess
and the given predicatep
holds for the right value, orFailure(msg)
if this is aSuccess
and the given predicatep
does not hold for the right value, orFailure
with the existing value ofFailure
if this is aFailure
.- Definition Classes
- Result
- Since
1.7.0
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[B, Errʹ >: Nothing](f: (A) => Result[Errʹ, B]): Result[Errʹ, B]
Returns the result of applying
f
to this result if it is a success.Returns the result of applying
f
to this result if it is a success. Returns a failure if this result is a failure. Differs frommap
asf
returns a result instead of just a value.- Definition Classes
- Result
- Since
1.7.0
- def flatten[B, Errʹ >: Nothing](implicit ev: <:<[A, Result[Errʹ, B]]): Result[Errʹ, B]
Returns the nested result if this result is a success, otherwise return this failure.
Returns the nested result if this result is a success, otherwise return this failure.
Equivalent to
flatMap(identity[Result[Errʹ, B]])
.- Definition Classes
- Result
- Since
1.7.0
- def fold[B](ferr: (Nothing) => B, fa: (A) => B): B
Returns the result of applying
ferr
to this result's error if this is aFailure
orfa
to the result stored in theSuccess
otherwise.Returns the result of applying
ferr
to this result's error if this is aFailure
orfa
to the result stored in theSuccess
otherwise.- ferr
the function to apply if this is a
Failure
.- fa
the function to apply if this is a
Success
.- returns
the results of applying the function
- Definition Classes
- Result
- Since
1.7.0
- def forall(f: (A) => Boolean): Boolean
Returns
true
if this result is aFailure
or returns the result of the application of the given predicate to theSuccess
value.Returns
true
if this result is aFailure
or returns the result of the application of the given predicate to theSuccess
value.- Definition Classes
- Result
- Since
1.7.0
- def foreach[U](f: (A) => U): Unit
Executes the procedure
f
if this is aSuccess
.Executes the procedure
f
if this is aSuccess
. Otherwise, do nothing.This is equivalent to:
result match { case Success(x) => f(x) case _ => () }
- f
The side-effecting function to execute.
- Definition Classes
- Result
- Since
1.7.0
- def get: A
Returns the successful value within the result.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getOrElse[B >: A](default: => B): B
Returns the value from this
Success
or the result of evaluatingdefault
if this is aFailure
.Returns the value from this
Success
or the result of evaluatingdefault
if this is aFailure
.- Definition Classes
- Result
- Since
1.7.0
- def isFailure: Boolean
Returns
true
if this is aFailure
,false
otherwise. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isSuccess: Boolean
Returns
true
if this is aSuccess
,false
otherwise. - def map[B](f: (A) => B): Result[Nothing, B]
Returns a
Success
containing the result of applyingf
to this result's value if this is a success.Returns a
Success
containing the result of applyingf
to this result's value if this is a success. Otherwise, returns a failure.- Definition Classes
- Result
- Since
1.7.0
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def orElse[B >: A, Errʹ >: Nothing](alternative: => Result[Errʹ, B]): Result[Errʹ, B]
Returns this result if it is a
Success
, otherwise return the result of evaluatingalternative
.Returns this result if it is a
Success
, otherwise return the result of evaluatingalternative
.- Definition Classes
- Result
- Since
1.7.0
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toEither: Either[Nothing, A]
Converts the
Result
into aEither
whereFailure
maps to aLeft[Err]
.Converts the
Result
into aEither
whereFailure
maps to aLeft[Err]
.- Definition Classes
- Result
- Since
1.7.0
- def toOption: Option[A]
Returns a
Some
containing theSuccess
value if it exists or aNone
if this is aFailure
.Returns a
Some
containing theSuccess
value if it exists or aNone
if this is aFailure
.- Definition Classes
- Result
- Since
1.7.0
- def toSeq: Seq[A]
Returns a
Seq
containing theSuccess
value if it exists or an emptySeq
if this is aFailure
.Returns a
Seq
containing theSuccess
value if it exists or an emptySeq
if this is aFailure
.- Definition Classes
- Result
- Since
1.7.0
- def toTry: Try[A]
Converts the
Result
into aTry
whereFailure
maps to a plainException
.Converts the
Result
into aTry
whereFailure
maps to a plainException
.- Definition Classes
- Result
- Since
1.7.0
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- val x: A