Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

case with an @ symbol in akka

I was reading through some examples of Akka, specifically the ChatServer example by Jonas Boner, and I came across case msg @ GetChatLog =>. I've tried to figure out what the @ symbol means by searching in akka documentation and various articles about pattern matching in scala with no luck. Does anyone have an idea of what it means?

like image 822
redeagle47 Avatar asked Aug 13 '14 15:08

redeagle47


1 Answers

@ binds the object being pattern matched to a variable. msg @ GetCharLog will result in msg holding a reference to the GetCharLog object, which isn't very useful. A better example is msg @ Foo(a, b, c), which will result in msg holding a reference to the instance of Foo that is matched on, which lets you forward the received message (for example) without needing to construct another instance of Foo with a, b, and c.

like image 142
pkinsky Avatar answered Nov 14 '22 13:11

pkinsky