https://kotlinlang.org logo
#compose-android
Title
# compose-android
m

Mahmoud Ali Yousuf

11/15/2023, 7:11 AM
what will be the main difference between if I create a
data class
or
sealed class
for the UI state?
a

andylamax

11/15/2023, 7:21 AM
for starters, you wouldn't be able to instantiate that sealed class unless you subclass it to a class. 2ndly, Another difference would be the lack of a copy method, which I happen to use most times I am doing UI states
👍 1
🤔 1
x

xoangon

11/15/2023, 6:52 PM
The recommendation is to always use data classes for stability reasons
👍 1
2 Views