Scala / Scala interview questions
What are Sealed classes in Scala?
Traits and classes can be marked sealed which means all subtypes must be declared in the same file. This assures that all subtypes are known.
sealed abstract class Communication case class VoiceCall() extends Communication case class Message() extends Communication def findPlaceToSit(commtype: Communication): String = commtype match { case a: VoiceCall => "Call him" case b: Message => "Message him" }
More Related questions...