This may be useful for:
- Describing the intention of the programmer (I created B, but I'm only interested in the behavior of A)
- Ensuring that you will only use the methods defined in A. This will replace the concrete later without changing much of your code.
- Simplify the autocomplete list available when using the IDE or REPL.
- Forced conversion at some point.
, .
sealed trait Answer
case object Yes extends Answer
case object No extends Answer
scala> val a = List( Yes, Yes, No )
a: List[Product with Serializable with Answer] = List(Yes, Yes, No)
scala> val b: List[Answer] = List( Yes, Yes, No )
b: List[Answer] = List(Yes, Yes, No)