How are case classes special in Scala?
This question already has an answer here:
Case class is different from normal class in following ways-
1) You can create instance of case class without new keyword
2) You can do pattern matching with case class
3) The constructor parameters of case classes are treated as public values and can be accessed directly like -
abstract class Term
case class Var(name: String) extends Term
val x = Var("x") println(x.name)
Please refer http://docs.scala-lang.org/tutorials/tour/case-classes.html and http://www.scala-lang.org/old/node/258
For more details about case classes
链接地址: http://www.djcxy.com/p/72826.html上一篇: 什么类型是特殊的Scala编译器?
下一篇: Scala中的case类如何特别?