gabrielfv
01/10/2020, 8:37 PMsealed class State<out T : Any>
object Loading : State</* Type isn't relevant here */>()
data class Loaded<T : Any>(data: T) : State<T>()
There's no reason for Loading
not to be an object in this context, neither is there any reason for it to specify a type. Changing the variance to contravariance and making it an Any
is a design flaw in this scenario. Is there any convenient alternative to what I'm trying to accomplish here?StavFX
01/10/2020, 9:41 PMobject Loading : State<Nothing>()
?gabrielfv
01/10/2020, 9:54 PMNothing
was a possibilityStavFX
01/10/2020, 9:55 PMNothing
, so I tend to forget about it too, but it’s really useful sometimesMatteo Mirk
01/13/2020, 9:20 AMNothing
! It works because it’s a subtype of any type (the opposite of Any) but can’t be instantiated.gabrielfv
01/13/2020, 6:53 PM