Search code examples
scalapattern-matchingakkaactor

Meaning of ref@Ping in akka receive


I was surfing some code examples on akka and I found a particular example that I would like to be sure of the meaning:

def receive: Receive = { case original@Ping(x) => // do stuff case _ => //do stuff }

Ping is a case class used for message in the example. But What's the meaning of that original@ ? Is it the message sender? if so, is there any advantage of this approach over using the sender variable?

Sorry, but I can't give you the link because I can't find it anymore...

Not sure if this Akka thing or just a advanced Scala pattern matching feature that I wasn't aware..


Solution

  • It is a Scala feature called variable binding. It binds the value being matched on to the variable. You can find more examples here Scala @ operator