What is called this syntax? And where is this explained in the Scala documentation?

Looking through the tutorial on Spray, I came across this:

entity(as[Quiz]) { quiz => requestContext =>
        val responder = createResponder(requestContext)
        createQuiz(quiz) match {
        case true => responder ! QuizCreated
        case _ => responder ! QuizAlreadyExists
    }
}

This particular line is where the confusion is:

entity(as[Quiz]) { quiz => requestContext =>

What's in the world with a second sign =>??? What does this syntax mean and where can I find documentation for further reading?

+4
source share
1 answer

If I put a parenthesis like this, does that make sense?

entity(as[Quiz]) { quiz => (requestContext =>
      ...  
      )
    }
}

It is simply a currency function with two arguments, and mechanically it is a function that returns another function. Example:

val test: Int => Int => Int = a => b => a + b // the same as a => (b => a + b)
println(test(2)(3))  //5

(a, b) => a + b, , :

val t: Int => Int = test(2)
println(t(3)) // 5
+6

Source: https://habr.com/ru/post/1625506/


All Articles