Raphael De Lio
1 min readJul 30, 2023

--

I don't say it's better, I say that runCatching and Result class "promote a functional programming style, making it easier to chain operations and handle results in a more idiomatic Kotlin way.".

And in the conclusion, I say that in most cases (almost ever in Business Logic), we shouldn't even use the Result class. We should just let exceptions bubble up.

But in the end, it's all a matter of preference. If you and your team prefer to have try/catches and find them more readable and maintainable, that shouldn't be a problem.

In the same way, many would prefer to iterate over a list using "for x in listOfX" instead of "listOfX.forEach()". I personally find the second more readable and concise, but I worked with many people who would prefer the first one. That's good to know our options and decide on each one to use consciously, though.

Thank you for the comment!

--

--

Raphael De Lio
Raphael De Lio

Written by Raphael De Lio

Software Engineer | Developer Advocate | International Conference Speaker | Tech Content Creator | Working @ Redis | https://linktr.ee/raphaeldelio

No responses yet