Hello. I really like kotlin result and want to use...
# getting-started
j
Hello. I really like kotlin result and want to use it in my app for fetching data etc as i can easily hook into onSuccess and onFailure. But as I am new to kotlin and android I found this SO where is recommended not to use kotlin result for things i actually want. https://stackoverflow.com/questions/70847513/when-and-how-to-use-result-in-kotlin . I would really love to know other people opinion.
e
I agree with the answer there. kotlin.Result is only good for generic machinery. otherwise, create and use your own types to represent what is actually possible in your problem domain. if you like the functions on Result, just make your own with the same names.
a
There are some alternative
Result
implementations that let you define your own error type (such as a sealed class); therefore you don't have the overhead of exceptions in normal business logic. • michaelbull/kotlin-resultforkhandles/result4k and its kotest-matchers I find kotlin-result is easier to use, but result4k already has a great kotest matcher library, and it integrates with my favourite functional http toolkit, so I prefer to use it.
🙌 1