13

Even more readable code without if-else

 4 years ago
source link: https://blog.frankel.ch/even-more-readable-code-without-if-else/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
A couple of years ago, I wrote a post focused on how to avoid sequences of if-else statements. In that post, I demo several alternatives: the usage of proper OOP designmapswhen there’s no return, switch statements in a case. Recently, I stumbled upon a slightly more complex use-case. This post describes it, and details what additional options are available in Kotlin. Modeling a simple if…​ else sequence Let’s start with modeling a simple sequence of if-else statement

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK