Scala gives us the sealed keyword, which allows the compiler to check at compile time that all cases of a type have been handled with So the compiler checks in compile-time - yes. - compile-time -that you handled all the cases.
Why is this insanely useful(IMO - the biggest advantages of scala over a lot of languages): let's take an example: When you write a calculator
Sealed trait Expression {
case class Add(left:Int,right:Int) extends Expression