Larry Garfield
05/10/2024, 3:01 PMCasey Brooks
05/10/2024, 3:04 PMLarry Garfield
05/10/2024, 3:05 PMLarry Garfield
05/10/2024, 3:06 PMCasey Brooks
05/10/2024, 3:07 PMLarry Garfield
05/10/2024, 3:07 PMif (some error) {
return Result.failure(CustomException())
}
return Result.success(value)
Larry Garfield
05/10/2024, 3:08 PMSam
05/10/2024, 3:10 PMEither
type if you want something betterLarry Garfield
05/10/2024, 3:11 PMCasey Brooks
05/10/2024, 3:16 PMMichael Krussel
05/10/2024, 3:17 PMEither
is in the core one.
You can also look at Kotlin's suggested alternatives. https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/result.md#similar-api-reviewMichael Krussel
05/10/2024, 3:19 PMephemient
05/10/2024, 3:20 PMAre exceptions particularly expensive to make, and then not actually throw?yes, because they capture stack trace
Larry Garfield
05/10/2024, 3:20 PMMichael Krussel
05/10/2024, 3:29 PMJavier
05/10/2024, 4:11 PMEither
you can copy it from Arrow. A lot of folks/companies do thatJavier
05/10/2024, 4:11 PMsimon.vergauwen
05/10/2024, 7:34 PMLarry Garfield
05/10/2024, 7:37 PMsimon.vergauwen
05/10/2024, 7:37 PMsimon.vergauwen
05/10/2024, 7:37 PMLarry Garfield
05/10/2024, 7:38 PMsimon.vergauwen
05/10/2024, 7:38 PMsimon.vergauwen
05/10/2024, 7:39 PMLarry Garfield
05/10/2024, 7:41 PMLarry Garfield
05/10/2024, 7:42 PMTim McCormack
05/11/2024, 12:18 AM