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

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -