zak.taccardi
11/23/2018, 7:01 PMlouiscad
11/23/2018, 7:03 PMIOException
should not be replaced by a sealed class everywhere (if anywhere at all) for examplezak.taccardi
11/23/2018, 7:04 PMTry<T>
in Scala/Arrow?louiscad
11/23/2018, 7:05 PMzak.taccardi
11/23/2018, 7:06 PMResult<T>
if you want that behavior downstreamlouiscad
11/23/2018, 7:10 PMzak.taccardi
11/23/2018, 7:17 PMResult<T>
. Downstream would be your Ui or ViewModel or something that calls that function.
It may be obvious to you, but it’s not going to be obvious to other developers. It’s why String?
in Kotlin is better than @Nullable String
in Java. One is enforced by the compiler, and one isn’t.
If you’re nesting multiple function calls that each return Result<T>
, then most implementations of `Result<T>`/`Try<T>`/etc have the ability to flatten Result<Result<T>>
into a single Result<T>
.
The reason I mentioned testing is that mocking/faking a method to return a Result.Success<T>
or a Result.Failure(exception)
is easier than telling a method to return a value or throwacando86
11/23/2018, 7:44 PM