I have read that case classes can be used with pattern matching. But, I am able to use a regular class with pattern matching as well. This question gives a regular scala perspective. I want it both from scala as well as akka perspective for this specific code. For example:
Actor class:
class TestActor extends Actor {
def receive={
case One(num)=>println("One "+num)
case t:Two=>println("Two "+t.num)
case _=>println("Another")
}
}
object TestActor{
case class One(num:Int)
}
Class Two:
class Two(var num:Int){ }
Main:
object Main2 extends App{
val system=ActorSystem("t")
val testActor=system.actorOf(Props[TestActor],"test")
val t=new Two(200)
val o=TestActor.One(100)
testActor!o
testActor!t
}
Output is:
One 100
Two 200
I know I am missing something here, probably in my understanding of pattern matching. Can someone help me out?