The companion object for Or providing factory methods for creating Ors from Eithers and Trys.
Attributes
Members list
Type members
Inherited types
The names of the product elements
The name of the type
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
Attributes
- 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
Attributes
- 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.
Attributes
- Returns
-
a new
OrwhoseGoodtype is theOption's type and whoseBadtype is the type of the passedorElseparameter. - Source
- Or.scala