Case classes becoming just cases

trait, class, object, enum – I have always wondered why “case class” would be the only double worded qualifier. Would it make sense to consider replacing “case class” definitions by “case”:

case Class1
case Class2(…) extends Class3

That would also align the syntax with Dotty’s new enums:

enum Color
{
case Red
case Blue
case Green
}

By extension we could allow a chained construct as in enums:

case Class1, Class2(…)

1 Like

I do not think it makes sense. Every case class is, above all, a class. In addition, it provides services that are related to structural equality and pattern matching (hence the case modifier). So it is a class, with additional case-related services. That deserves the two words.

4 Likes

It might be worth pointing out that there are case objects as well as classes.

2 Likes