scala - Why are constructor parameters made into members for case classes? -
{ class myclass(name: string) {} val x = new myclass("x") println(x.name) // error name not member of myclass }
but
{ abstract class base case class myclass(name: string) extends base {} var x = new myclass("x") println(x.name) // name member of myclass }
so, what's deal case classes? why of constructor parameters turned variables.
name
member in both examples, private in first example while public in second. case classes make constructor parameters public val
default.
Comments
Post a Comment