Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of tilde arrow in this context?

Tags:

scala

akka

spray

This is the code from https://github.com/eigengo/activator-spray-twitter/blob/master/src/main/scala/core/tweetstream.scala

What ~>(tilde arrow) operator does? I think that must be a operator of HttpRequest, but I could not find such operator in spray API.

I can figure out that authorize is a function which returns (HttpRequest => HttpRequest), so val rq must be a HttpRequest which returned value after applied by returned function of authorize.

def receive: Receive = {
    case query: String =>
      val body = HttpEntity(ContentType(MediaTypes.`application/x-www-form-urlencoded`), s"track=$query")
      val rq = HttpRequest(HttpMethods.POST, uri = uri, entity = body) ~> authorize
      sendTo(io).withResponsesReceivedBy(self)(rq)
    case ChunkedResponseStart(_) =>
    case MessageChunk(entity, _) => TweetUnmarshaller(entity).fold(_ => (), processor !)
    case _ =>
  }

Thanks in advance!

like image 563
nine Avatar asked Oct 21 '22 10:10

nine


1 Answers

The operator is just a function, and it is defined implicitly, see line 32 here.

Just think of it as compose. The operator takes the value to the left, and stuffs it as input into the function to the right.

A tip for how to find out things like these for yourself: Load the project into intellij idea or scala-IDE and just ctrl-click on the symbol. The IDE will take you to the definition.

like image 123
rompetroll Avatar answered Nov 15 '22 07:11

rompetroll