Checking Success or Failure
How to find out if the operation succeded or failed
As we discovered earlier, we can easily determine if a given Result
instance is successful or not.
Checking Success
We can use Result::hasSuccess
to obtain a boolean
value that represents whether a result is successful.
Checking Failure
We can also use Result::hasFailure
to find out if a result contains a failure value.
Conclusion
We discussed how to determine the state of a Result object using hasSuccess
and hasFailure
. These methods provide a straightforward way to identify the outcome of an operation, helping you make decisions based on the outcome.
Last updated