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?
@ 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With