Hey I am a noob learning Kotlin and I don't know J...
# announcements
a
Hey I am a noob learning Kotlin and I don't know Java. Can someone help me understand the difference between sealed classes and enums? Am I right in assuming enums are like singleton sealed classes?
n
- sealed classes mean a class cannot be inherited beside those already declared in the same file (if i remember well) - enums are well, enumerations, like value types from the same type. and yes, they are singletons
a
All right. That makes it a bit clearer. So if I want I can use sealed classes like enums too, right?
n
what is your use-case?
a
Well lets say I want to implement a Msg type, where it sends a subtype
Err
if it receives an
Err
or sends a subtype
NewMsg(text : String)
when it receives a new message
f
watch this part about sealed class

https://youtu.be/X1RVYt2QKQE?t=1568