Good

final case class Good[+G](g: G) extends Or[G, Nothing]

Contains a “good” value.

You can decide what “good” means, but it is expected Good will be commonly used to hold valid results for processes that may fail with an error instead of producing a valid result.

Value parameters:
g

the “good” value

Companion:
object
Source:
Or.scala
class Or[G, Nothing]
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def accumulating: Or[G, One[Nothing]]
Source:
Or.scala
def badMap[C](f: Nothing => C): Or[G, C]
Source:
Or.scala
def exists(p: G => Boolean): Boolean
Source:
Or.scala
def filter[C](f: G => Validation[C]): Or[G, C]
Source:
Or.scala
def flatMap[H, C](f: G => Or[H, C]): Or[H, C]
Source:
Or.scala
def fold[V](gf: G => V, bf: Nothing => V): V
Source:
Or.scala
def forall(p: G => Boolean): Boolean
Source:
Or.scala
def foreach(f: G => Unit): Unit
Source:
Or.scala
def get: G
Source:
Or.scala
def getOrElse[H >: G](default: => H): G
Source:
Or.scala
def map[H](f: G => H): Or[H, Nothing]
Source:
Or.scala
def orBad[C]: Or[G, C]

Narrows the Bad type of this Good to the given type.

Narrows the Bad type of this Good to the given type.

Because Or has two types, but the Good factory method only takes a value of the “good” type, the Scala compiler will infer Nothing for the Bad type:

scala> Good(3)
res0: org.scalactic.Good[Int,Nothing] = Good(3)

Often Nothing will work fine, as it will be widened as soon as the compiler encounters a more specific Bad type. Sometimes, however, you may need to specify it. In such situations you can use this orBad method, like this:

scala> Good(3).orBad[String]
res1: org.scalactic.Good[Int,String] = Good(3)
Source:
Or.scala
def orElse[H >: G, C](alternative: => Or[H, C]): Or[G, Nothing]
Source:
Or.scala
def recover[H >: G](f: Nothing => H): Or[H, Nothing]
Source:
Or.scala
def recoverWith[H >: G, C](f: Nothing => Or[H, C]): Or[H, C]
Source:
Or.scala
def swap: Or[Nothing, G]
Source:
Or.scala
def toEither: Either[Nothing, G]
Source:
Or.scala
def toOption: Some[G]
Source:
Or.scala
def toSeq: IndexedSeq[G]
Source:
Or.scala
def toTry(implicit ev: Nothing <:< Throwable): Success[G]
Source:
Or.scala
def transform[H, C](gf: G => Or[H, C], bf: Nothing => Or[H, C]): Or[H, C]
Source:
Or.scala

Deprecated methods

@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).")
override def asOr: Or[G, Nothing]

The asOr method has been deprecated and will be removed in a future version of Scalactic. Please remove invocations of asOr in expressions of type Good(value).orBad[Type] and Good[Type].orBad(value) (which now return a type already widened to Or), otherwise please use a type annotation to widen the type, such as: (Good(3): Int Or ErrorMessage).

The asOr method has been deprecated and will be removed in a future version of Scalactic. Please remove invocations of asOr in expressions of type Good(value).orBad[Type] and Good[Type].orBad(value) (which now return a type already widened to Or), otherwise please use a type annotation to widen the type, such as: (Good(3): Int Or ErrorMessage).

Deprecated
Definition Classes
Source:
Or.scala

Inherited methods

def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product
def withFilter[C](f: G => Validation[C]): Or[G, C]

Currently just forwards to filter, and therefore, returns the same result.

Currently just forwards to filter, and therefore, returns the same result.

Inherited from:
Or
Source:
Or.scala

Concrete fields

override val isGood: Boolean
Source:
Or.scala

Inherited fields

val isBad: Boolean

Indicates whether this Or is a Bad

Indicates whether this Or is a Bad

Returns:

true if this Or is a Bad, false if it is a Good.

Inherited from:
Or
Source:
Or.scala