Let's continue with our Weather
example .
The super-sealed classes have additional "special" pattern matching methods that allow you to map between the different modddels. In our example, these methods are : mapWeather
, maybeMapWeather
and mapOrNullWeather
.
For Example :
These methods can be used on all the super-sealed classes :
Weather
Sunny
- Rainy
ValidWeather
ValidSunny
- ValidRainy
InvalidWeather
InvalidSunny
- InvalidRainy
InvalidWeatherValue
InvalidSunnyValue
- InvalidRainyValue
For Example :
Notice how the type of the callback parameters changes according to which super-sealed class the mapWeather
method is called on.