Andrew
04/12/2021, 2:17 PMsealed class Fruit
object Apple : Fruit()
object Banana : Fruit()
vs
sealed class Fruit {
object Apple : Fruit()
object Banana : Fruit()
}ephemient
04/12/2021, 2:19 PMephemient
04/12/2021, 2:19 PMNir
04/12/2021, 2:20 PMApple and Banana, in the second, Fruit.Apple and Fruit.Bananawbertan
04/12/2021, 2:20 PMApple for example, while other you use Fruit.Apple.
So if in the same scope you have like Brands with Apple too, the first example will complain as you would have two Apple objects, while the second should be fine as you access as Brands.Apple.Nir
04/12/2021, 2:20 PMwbertan
04/12/2021, 2:21 PMViewModelAEvent.Navigate and ViewModelBEvent.NavigateAndrew
04/12/2021, 2:23 PMMichael Böiers
04/12/2021, 3:06 PMephemient
04/12/2021, 3:40 PMnanodeath
04/12/2021, 3:52 PMephemient
04/12/2021, 4:00 PMMichael Böiers
04/12/2021, 8:11 PMephemient
04/12/2021, 8:16 PMephemient
04/12/2021, 8:18 PMephemient
04/12/2021, 8:19 PMMichael Böiers
04/12/2021, 8:25 PMMichael Böiers
04/12/2021, 8:27 PMclass Foo {
sealed class Fruit
data class Apple(val name: String): Fruit() // Fruit is not accessible
}ephemient
04/12/2021, 10:13 PMMichael Böiers
04/13/2021, 5:48 AM