Result
A result class models the possibility of a success or failure event occurring.
A success is modeled by the Ok subtype, while an error is modeled by the Err subtype. While neither type is different (they are both wrappers around one value), the "left" type (T
) represents a success, while the "right" (E
) represents failure.
This is similar to the Result
type in Rust and Scala.
Do NOT use this class to model anything but success and failure. For example, don't use it to model a method that could return two possible types if they're both successful outcomes. The semantics would be wrong.
Ok and Err are the only two possible subtypes.
For Ok, a value will be present of type T
, retrievable via .getOrNull or the other get
methods.
For Err, a value will be present of type E
, retrievable via .getErr