DEV Community

Discussion on: How to write cleaner functions.

patricnox profile image

Interesting article you wrote there!

I don't really agree with the switch case argument.

Arguably, it's way more clean looking when it comes to input handling. I tend to use it for preprocessing variables before transmitting them to a output or similar, it's nice to have them scoped.

Besides, 5 if conditions looks quite bad. Refactored to s switch case looks way better and much easier to read.

I'd probably also would love for the article to provide more proof of concepts to the arguments written.

it's very nice anywho. ✔️

rektdeckard profile image
Tobias Fried

Kotlin when statement/expressions FTW

genspirit profile image

Personally, I'm a fan of just using a Map instead of a switch. For me switch statements just seem overly verbose and less intuitive.

olayemii profile image

Totally agree, switch is cleaner..

singh1114 profile image
Ranvir Singh Author • Edited on

I have to totally agree with @genspirit up here. Even I always prefer Map, dicts against switch statements. I have updated the article accordingly. Do give a look and let me know.