object Good extends Serializable
Companion object for Good
that offers, in addition to the standard factory method
for Good
that takes single “good” type, an parameterless apply
used to narrow the Good
type when creating a Bad
.
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- Good
- Serializable
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Type Members
Value Members
- def apply[G]: GoodType[G]
Captures a
Good
type to enable aBad
to be constructed with a specificGood
type.Captures a
Good
type to enable aBad
to be constructed with a specificGood
type.Because
Or
has two types, but theBad
factory method only takes a value of the “bad” type, the Scala compiler will inferNothing
for theGood
type:scala> Bad("oops") res1: org.scalactic.Bad[Nothing,String] = Bad(oops)
Often
Nothing
will work fine, as it will be widened as soon as the compiler encounters a more specificGood
type. Sometimes, however, you may need to specify it. In such situations you can use this factory method, like this:scala> Good[Int].orBad("oops") res3: org.scalactic.Bad[Int,String] = Bad(oops)