spark系列case class学习

scala> case class Message(sender: String, recipient: String, body: String)
defined class Message

scala> val message1 = Message("[email protected]", "[email protected]", "Ça va ?")
message1: Message = Message(guillaume@quebec.ca,jorge@catalonia.es,Ça va ?)

scala> 

scala> println(message1.sender)  // prints [email protected]
guillaume@quebec.ca
//不能进行赋值操作
scala> message1.sender = "[email protected]"  // this line does not compile
:27: error: reassignment to val
       message1.sender = "[email protected]"  // this line does not compile
                       ^

scala> message1.sender = "[email protected]"
:27: error: reassignment to val
       message1.sender = "[email protected]"

spark系列case class学习_第1张图片

你可能感兴趣的:(scala)