The companion object for Or providing factory methods for creating Ors from Eithers and Trys.
Type members
Inherited types
The names of the product elements
The names of the product elements
- Inherited from:
- Mirror
- Source:
- Mirror.scala
Value members
Concrete methods
Constructs a new Or from the given Try.
Constructs a new Or from the given Try.
- Value parameters:
- theTry
the
Tryto convert to anOr
- Returns:
a new
OrwhoseGoodtype is theTry'sSuccesstype and whoseBadtype isThrowable.- Source:
- Or.scala
Constructs a new Or from the given Either.
Constructs a new Or from the given Either.
Note that values effectively “switch sides” when converting an Either to an Or. If the type of the
Either which you pass to Or.from is Either[ErrorMessage, Int] for example, the result will be an
Or[Int, ErrorMessage]. The reason is that the convention for Either is that Left is used for “bad”
values and Right is used for “good” ones. If you with to keep the types on the same side, invoke swap on the
Either before passing it to from.
- Value parameters:
- either
the
Eitherto convert to anOr
- Returns:
a new
OrwhoseGoodtype is theEither'sRighttype and whoseBadtype isEither'sLefttype.- Source:
- Or.scala
Constructs a new Or from the given Option.
Constructs a new Or from the given Option.
- Value parameters:
- option
the
Optionto convert to anOr- orElse
the
Badvalue to use if theOptionpassed asoptionisNone.
- Returns:
a new
OrwhoseGoodtype is theOption's type and whoseBadtype is the type of the passedorElseparameter.- Source:
- Or.scala