Skip to content

Instantly share code, notes, and snippets.

@2m
Created March 20, 2014 10:28
Show Gist options
  • Save 2m/9660966 to your computer and use it in GitHub Desktop.
Save 2m/9660966 to your computer and use it in GitHub Desktop.
akka receive implementation using scala and java lamda
// scala
def receive = {
case Counter.Inc(by) => count += by
case Counter.Current => sender ! Counter.CurrentReply(count)
}
// java lamda
@Override
public PartialFunction<Object, BoxedUnit> receive() {
return ReceiveBuilder.
match(Inc.class, inc -> {
count += inc.by;
}).
match(Current.class, current -> {
sender().tell(new CurrentReply(count), self());
}).
build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment