final case class Bad[+B](b: B) extends Or[Nothing, B] with Product with Serializable
Contains a “bad” value.
You can decide what “bad” means, but it is expected Bad will be commonly used
to hold descriptions of an error (or several, accumulated errors). Some examples of possible error descriptions
are String error messages, Int error codes, Throwable exceptions,
or instances of a case class hierarchy designed to describe errors.
- b
- the “bad” value 
- Source
- Or.scala
- Alphabetic
- By Inheritance
- Bad
- Or
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
-    new Bad(b: B)- b
- the “bad” value 
 
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
 
-    def accumulating: Or[Nothing, One[B]]Converts this Orto anOrwith the sameGoodtype and aBadtype consisting ofOneparameterized by thisOr'sBadtype.Converts this Orto anOrwith the sameGoodtype and aBadtype consisting ofOneparameterized by thisOr'sBadtype.For example, invoking the accumulatingmethod on anInt Or ErrorMessagewould convert it to anInt Or One[ErrorMessage]. This result type, because theBadtype is anEvery, can be used with the mechanisms provided in traitAccumulationto accumulate errors.Note that if this Oris already an accumulatingOr, the behavior of thisaccumulatingmethod does not change. For example, if you invokeaccumulatingon anInt Or One[ErrorMessage]you will be rewarded with anInt Or One[One[ErrorMessage]].- returns
- this - Good, if this- Oris a- Good; or this- Badvalue wrapped in a- Oneif this- Oris a- Bad.
 
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-  val b: B
-    def badMap[C](f: (B) => C): Or[Nothing, C]Maps the given function to this Or's value if it is aBador returnsthisif it is aGood.
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
 
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def exists(p: (Nothing) => Boolean): BooleanReturns trueif thisOris aGoodand the predicatepreturns true when applied to thisGood's value.Returns trueif thisOris aGoodand the predicatepreturns true when applied to thisGood's value.Note: The existsmethod will return the same result asforallif thisOris aGood, but the opposite result if thisOris aBad.- p
- the predicate to apply to the - Goodvalue, if this is a- Good
- returns
- the result of applying the passed predicate - pto the- Goodvalue, if this is a- Good, else- false
 
-    def filter[C >: B](f: (Nothing) => Validation[C]): Or[Nothing, C]Returns this Orif either 1) it is aBador 2) it is aGoodand applying the validation functionfto thisGood's value returnsPass; otherwise, returns a newBadcontaining the error value contained in theFailresulting from applying the validation functionfto thisGood's value.Returns this Orif either 1) it is aBador 2) it is aGoodand applying the validation functionfto thisGood's value returnsPass; otherwise, returns a newBadcontaining the error value contained in theFailresulting from applying the validation functionfto thisGood's value.For examples of filterused inforexpressions, see the main documentation for traitValidation.- f
- the validation function to apply 
- returns
- a - Goodif this- Oris a- Goodthat passes the validation function, else a- Bad.
 
-    def finalize(): Unit- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
 
-    def flatMap[H, C >: B](f: (Nothing) => Or[H, C]): Or[H, C]Returns the given function applied to the value contained in this Orif it is aGood, or returnsthisif it is aBad.Returns the given function applied to the value contained in this Orif it is aGood, or returnsthisif it is aBad.- f
- the function to apply 
- returns
- if this is a - Good, the result of applying the given function to the contained value wrapped in a- Good, else this- Badis returned
 
-    def fold[V](gf: (Nothing) => V, bf: (B) => V): VFolds this Orinto a value of typeVby applying the givengffunction if this is aGoodelse the givenbffunction if this is aBad.Folds this Orinto a value of typeVby applying the givengffunction if this is aGoodelse the givenbffunction if this is aBad.- gf
- the function to apply to this - Or's- Goodvalue, if it is a- Good
- bf
- the function to apply to this - Or's- Badvalue, if it is a- Bad
- returns
- the result of applying the appropriate one of the two passed functions, - gfor bf, to this- Or's value
 
-    def forall(p: (Nothing) => Boolean): BooleanReturns trueif either thisOris aBador if the predicatepreturnstruewhen applied to thisGood's value.Returns trueif either thisOris aBador if the predicatepreturnstruewhen applied to thisGood's value.Note: The forallmethod will return the same result asexistsif thisOris aGood, but the opposite result if thisOris aBad.- p
- the predicate to apply to the - Goodvalue, if this is a- Good
- returns
- the result of applying the passed predicate - pto the- Goodvalue, if this is a- Good, else- true
 
-    def foreach(f: (Nothing) => Unit): UnitApplies the given function f to the contained value if this Oris aGood; does nothing if thisOris aBad.
-    def get: NothingReturns the Or's value if it is aGoodor throwsNoSuchElementExceptionif it is aBad.
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-    def getOrElse[H](default: => H): HReturns, if this OrisGood, thisGood's value; otherwise returns the result of evaluatingdefault.
-  val isBad: Boolean
-    val isGood: BooleanIndicates whether this Oris aGoodIndicates whether this Oris aGood- returns
- true if this - Oris a- Good,- falseif it is a- Bad.
 - Definition Classes
- Or
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-    def map[H](f: (Nothing) => H): Or[H, B]Maps the given function to this Or's value if it is aGoodor returnsthisif it is aBad.
-   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[H, C >: B](alternative: => Or[H, C]): Or[H, C]Returns this Orif it is aGood, otherwise returns the result of evaluating the passedalternative.
-    def productElementNames: Iterator[String]- Definition Classes
- Product
 
-    def recover[H](f: (B) => H): Or[H, B]Maps the given function to this Or's value if it is aBad, transforming it into aGood, or returnsthisif it is already aGood.Maps the given function to this Or's value if it is aBad, transforming it into aGood, or returnsthisif it is already aGood.- f
- the function to apply 
- returns
- if this is a - Bad, the result of applying the given function to the contained value wrapped in a- Good, else this- Goodis returned
 
-    def recoverWith[H, C](f: (B) => Or[H, C]): Or[H, C]Maps the given function to this Or's value if it is aBad, returning the result, or returnsthisif it is already aGood.
-    def swap: Or[B, Nothing]Returns an Orwith theGoodandBadtypes swapped:BadbecomesGoodandGoodbecomesBad.Returns an Orwith theGoodandBadtypes swapped:BadbecomesGoodandGoodbecomesBad.Here's an example: scala> val lyrics = Bad("Hey Jude, don't make it bad. Take a sad song and make it better.") lyrics: org.scalactic.Bad[Nothing,String] = Bad(Hey Jude, don't make it bad. Take a sad song and make it better.) scala> lyrics.swap res12: org.scalactic.Or[String,Nothing] = Good(Hey Jude, don't make it bad. Take a sad song and make it better.)Now that song will be rolling around in your head all afternoon. But at least it is a good song (thanks to swap).- returns
- if this - Oris a- Good, its- Goodvalue wrapped in a- Bad; if this- Oris a- Bad, its- Badvalue wrapped in a- Good.
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-    def toEither: Either[B, Nothing]Returns an Either: aRightcontaining theGoodvalue, if this is aGood; aLeftcontaining theBadvalue, if this is aBad.Returns an Either: aRightcontaining theGoodvalue, if this is aGood; aLeftcontaining theBadvalue, if this is aBad.Note that values effectively “switch sides” when convering an Orto anEither. If the type of theOron which you invoketoEitherisOr[Int, ErrorMessage]for example, the result will be anEither[ErrorMessage, Int]. The reason is that the convention forEitheris thatLeftis used for “bad” values andRightis used for “good” ones.- returns
- this - Goodvalue, wrapped in a- Right, or this- Badvalue, wrapped in a- Left.
 
-    def toOption: None.typeReturns a Somecontaining theGoodvalue, if thisOris aGood, elseNone.
-    def toSeq: IndexedSeq[Nothing]Returns an immutable IndexedSeqcontaining theGoodvalue, if thisOris aGood, else an empty immutableIndexedSeq.
-    def toTry(implicit ev: <:<[B, Throwable]): Failure[Nothing]Returns a Try: aSuccesscontaining theGoodvalue, if this is aGood; aFailurecontaining theBadvalue, if this is aBad.Returns a Try: aSuccesscontaining theGoodvalue, if this is aGood; aFailurecontaining theBadvalue, if this is aBad.Note: This method can only be called if the Badtype of thisOris a subclass ofThrowable(orThrowableitself).Note that values effectively “switch sides” when converting an Orto anEither. If the type of theOron which you invoketoEitherisOr[Int, ErrorMessage]for example, the result will be anEither[ErrorMessage, Int]. The reason is that the convention forEitheris thatLeftis used for “bad” values andRightis used for “good” ones.- returns
- this - Goodvalue, wrapped in a- Right, or this- Badvalue, wrapped in a- Left.
 
-    def transform[H, C](gf: (Nothing) => Or[H, C], bf: (B) => Or[H, C]): Or[H, C]Transforms this Orby applying the functiongfto thisOr'sGoodvalue if it is aGood, or by applyingbfto thisOr'sBadvalue if it is aBad.Transforms this Orby applying the functiongfto thisOr'sGoodvalue if it is aGood, or by applyingbfto thisOr'sBadvalue if it is aBad.- gf
- the function to apply to this - Or's- Goodvalue, if it is a- Good
- bf
- the function to apply to this - Or's- Badvalue, if it is a- Bad
- returns
- the result of applying the appropriate one of the two passed functions, - gfor bf, to this- Or's value
 
-   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()
 
-    def withFilter[C >: B](f: (Nothing) => Validation[C]): Or[Nothing, C]Currently just forwards to filter, and therefore, returns the same result. Currently just forwards to filter, and therefore, returns the same result. - Definition Classes
- Or
 
Deprecated Value Members
-    def asOr: Or[Nothing, B]The asOrmethod has been deprecated and will be removed in a future version of Scalactic. Please remove invocations ofasOrin expressions of typeGood(value).orBad[Type]andGood[Type].orBad(value)(which now return a type already widened toOr), otherwise please use a type annotation to widen the type, such as:(Good(3): Int Or ErrorMessage).The asOrmethod has been deprecated and will be removed in a future version of Scalactic. Please remove invocations ofasOrin expressions of typeGood(value).orBad[Type]andGood[Type].orBad(value)(which now return a type already widened toOr), otherwise please use a type annotation to widen the type, such as:(Good(3): Int Or ErrorMessage).- Definition Classes
- Bad → Or
- Annotations
- @deprecated
- Deprecated
- The asOr is no longer needed because Good(value).orBad[Type] and Good[Type].orBad(value) now return Or. You can delete invocations of asOr in those cases, otherwise, please use a type annotation to widen the type, like (Good(3): Int Or ErrorMessage).