The companion object for Or
providing factory methods for creating Or
s from Either
s and Try
s.
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
Try
to convert to anOr
- Returns:
a new
Or
whoseGood
type is theTry
'sSuccess
type and whoseBad
type 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
Either
to convert to anOr
- Returns:
a new
Or
whoseGood
type is theEither
'sRight
type and whoseBad
type isEither
'sLeft
type.- Source:
- Or.scala
Constructs a new Or
from the given Option
.
Constructs a new Or
from the given Option
.
- Value parameters:
- option
the
Option
to convert to anOr
- orElse
the
Bad
value to use if theOption
passed asoption
isNone
.
- Returns:
a new
Or
whoseGood
type is theOption
's type and whoseBad
type is the type of the passedorElse
parameter.- Source:
- Or.scala