Scala case classes in depth

For this post I’ll consider the following simple case class unless otherwise specified: caseclassPerson(lastname:String,firstname:String,birthYear:Int) Common knowledge about case classes When you declare a case class the Scala compiler does the following for you: Creates a class and its companion object. Implements the apply method that you can use as a factory. This lets you create instances of the class without the new keyword. E.g.: valp=Person("Lacava","Alessandro",1976)// instead of the slightly more verbose: valp=newPerson("Lacava","Alessandro",1976) Prefixes all arguments, in the parameter list, with val.