Is it okay to nest sealed classes. So UserData is...
# getting-started
i
Is it okay to nest sealed classes. So UserData is a part of ModelData, but UserData can also have its own hierarchy with two separate types of UserData, in this case LoginData and AuthenticationData. Or is there any better solution for this?
m
from my experience, it's fine 🙂
m
are you sure this example is what you want? Because
UserLoginData
and
UserAuthenticationData
do not extend
ModelData
, and if you try to assign for example an instance of
UserLoginData
to
ModelData
or do an
is
check, you’ll get a complation error. Am I missing something? 🤔
i
Yeah, my bad it should be
Copy code
sealed class UserData(...): ModelData() {
		
		data class UserLoginData(...): UserData()
		data class UserAuthenticationData(...): UserData()
	}
m
Oh okay thanks, I was confused!