Hullaballoonatic
11/02/2019, 8:34 PMfizz
returned nullable, then foo.fizz()?.log()
william
11/02/2019, 8:35 PMHullaballoonatic
11/02/2019, 8:36 PMToddobryan
11/02/2019, 8:36 PMwilliam
11/02/2019, 8:38 PMHullaballoonatic
11/02/2019, 8:38 PMwilliam
11/02/2019, 8:39 PMHullaballoonatic
11/02/2019, 8:39 PMval Foo.error get() = foo.fizz().let { if (it.isNotNone()) it else null }
or something
oh, alright. well, idk. examples.Toddobryan
11/02/2019, 8:40 PMhandle
function that puts all the error handling in one place. Then it's just
handle(foo.fizz())
handle(foo.buzz())
...
foo.fizz().handle()
foo.buzz().handle()
william
11/02/2019, 8:41 PMhandle(
foo.fizz(),
foo.buzz()
)
...
private fun handle(vararg operations: Error) {
operations.forEach { op ->
if (op != Error.NONE ) {
// ...
}
}
}
Toddobryan
11/02/2019, 8:53 PMblock
there to solve the lazy issue, but you'd still have to wrap each call in some kind of function to check the result.william
11/02/2019, 8:57 PMToddobryan
11/02/2019, 8:57 PMwilliam
11/02/2019, 8:59 PMToddobryan
11/02/2019, 8:59 PMsomeFun {
foo.fizz()
foo.buzz()
...
}
means the functions don't need to be lazy and lets you exit early on a severe-enough error, but doesn't help at all with the fact that you'd still have to handle each error individually somehow. 😞william
11/02/2019, 9:05 PM