Destructuring in when

Destructuring in kotlin is done using the componentN functions marked with the operator keyword. You can define them for any class starting with component1. Data classes automatically generate them.
https://kotlinlang.org/docs/reference/multi-declarations.html#destructuring-declarations

1 Like