Kotlin coding conventions denotes that we should prefer if for binary and when for three or more options.

  1. Why?
  2. Why is when preferred for three or more options?
  3. Why IntelliJ IDEA/Android studio warns us with “Cascade if should be replaced with when”?

#kotlin-extension #functional-programming #kotlin #java #if-else

Avoid cascading if-else in Kotlin
4.60 GEEK