utils.Result
See theResult companion object
A type representing either a successful value or an error.
Result[T, E] is similar to Either[E, T] but with more intuitive naming where T represents the success type and E represents the error type. This is commonly used for error handling without exceptions.
Type parameters
- E
-
the type of the error value
- T
-
the type of the success value
Attributes
- Example
-
val success: Result[Int, String] = Result.Success(42) val failure: Result[Int, String] = Result.Failure("Something went wrong") val doubled = success.map(_ * 2) // Result.Success(84) val errorResult = failure.map(_ * 2) // Result.Failure("Something went wrong") - Companion
- object
- Graph
-
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
Members list
In this article