Hi Folks, I wanted advice regarding structuring a ...
# general-advice
a
Hi Folks, I wanted advice regarding structuring a sealed class hierarchy with generics, Lets say I have a sealed class with 2 child classes and one of them needs to be generic, should I make the parent class also generic or only the child class as generic. Basically which one is preferred ->
Copy code
// Sealed class without generics
sealed class Result

// Subclass with a generic type
data class Success<T>(val data: T) : Result()

// Subclass without a generic type
object Loading : Result()
Or
Copy code
sealed class Result<T>

class Success<T>(val data: T) : Result<T>()

// Some other subclass that doesn't need T can be defined as
class Error(val message: String) : Result<Nothing>()