How to define a case class in Scala

1 Answer

0 votes
object MyClass {
    
    case class Message(from: String, to: String, body: String)
     
    def main(args: Array[String]): Unit = {
       
        val message = Message("fromme@collectivesolver.com", "toyou@seek4info.com", "Let's Code")

        println(message.from)  
        println(message.to)  
        println(message.body)  
    }
}




/*
run:

fromme@collectivesolver.com
toyou@seek4info.com
Let's Code

*/

 



answered Dec 27, 2022 by avibootz
...