In Kotlin, when is already so powerful but did you know you can also use custom objects in when? Amazing, right? Let's go about implementing it.
Using when with custom objects
Getting ready
You need to install a preferred development environment that compiles and runs Kotlin. You can also use the command line for this purpose, for which you need Kotlin compiler installed, along with JDK. I am using the command line to compile and run my Kotlin code for this recipe.
How to do it...
Create a file and name it whenWithObject.kt, and then, let's try when with a custom...