sealed abstract class Result[+Err, +A] extends AnyRef
This trait represents the result of a parser.
Either a Success[A]
or a Failure
.
- A
the type of expected success result.
- Source
- Result.scala
- Alphabetic
- By Inheritance
- Result
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def get: A
Returns the successful value within the result.
Returns the successful value within the result.
This is equivalent to:
result match { case Success(x) => x case _ => throw new Exception }
- Since
1.7.0
- Exceptions thrown
java.util.NoSuchElementException
if the result is a failure.- Note
the result must not be a failure.
- abstract def isFailure: Boolean
Returns
true
if this is aFailure
,false
otherwise.Returns
true
if this is aFailure
,false
otherwise.- Since
1.7.0
- abstract def isSuccess: Boolean
Returns
true
if this is aSuccess
,false
otherwise.Returns
true
if this is aSuccess
,false
otherwise.- Since
1.7.0
Concrete 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
.
- Since
1.7.0
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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.- Since
1.7.0
- def filterOrElse[Errʹ >: Err](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
.- Since
1.7.0
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[B, Errʹ >: Err](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.- Since
1.7.0
- def flatten[B, Errʹ >: Err](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]])
.- Since
1.7.0
- def fold[B](ferr: (Err) => 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
- 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.- 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.
- Since
1.7.0
- 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
.- Since
1.7.0
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) => B): Result[Err, 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.- 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ʹ >: Err](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
.- Since
1.7.0
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toEither: Either[Err, A]
Converts the
Result
into aEither
whereFailure
maps to aLeft[Err]
.Converts the
Result
into aEither
whereFailure
maps to aLeft[Err]
.- 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
.- 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
.- Since
1.7.0
- def toString(): String
- Definition Classes
- AnyRef → Any
- def toTry: Try[A]
Converts the
Result
into aTry
whereFailure
maps to a plainException
.Converts the
Result
into aTry
whereFailure
maps to a plainException
.- 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()