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

Abimbola Esuruoso

Going through a tutorial on Spray, I encountered this:

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

This specific line is where the confusion lies:

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

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

Archeg

If I put the parenthesis like this, does it make more sense?

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

This is just a curried 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

You can think of it as (a, b) => a + b, but with the added benefit so you can partially apply it easier:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

ORACLE syntax: What is this called?

From Dev

PHP Weird Syntax - What is it called?

From Dev

What language used in scala documentation in lexical expressions?

From Dev

What is the syntax and semantics of the `where` keyword?

From Dev

What does glGenVertexArraysOES() do and where is the documentation?

From Dev

What does glGenVertexArraysOES() do and where is the documentation?

From Dev

XML ellipsis / other syntax - what's it called?

From Dev

What is SpreadElement in ECMAScript documentation? Is it the same as Spread syntax at MDN?

From Dev

What is the use cases of Ignored Variable syntax in Scala?

From Dev

What feature of Scala allows for Props[SomeActor] syntax

From Dev

What does the syntax function[T] means in scala

From Dev

Scala match syntax: What is the block like structure

From Dev

In Scala, what syntax rules apply to foreach(println)?

From Dev

What is this C# Syntax called and what does it do?

From Dev

What is this C# Syntax called and what does it do?

From Dev

What is polymorphism, explained simply?

From Dev

ExtLibUtil documentation - where do you find what the available functions are?

From Dev

What is the name of "${}" and where can I find documentation on them for NetBeans IDE?

From Dev

ExtLibUtil documentation - where do you find what the available functions are?

From Dev

What does a bash sequence '\033[999D' mean and where is it explained?

From Dev

where are the function key row keys explained for the dell inspiron N5010, what does the "A" key do?

From Dev

Strange syntax in CImg library, don't know what it's called

From Dev

can anyone tell me how this syntax is called and what it does?

From Dev

What is "search: { ... }" / "break search" syntax officially called in Java?

From Dev

Strange syntax in CImg library, don't know what it's called

From Dev

What is this Javascrip/node variable/constant assinging notation/syntax called ?

From Dev

Where the architecture of iOS apps is explained?

From Dev

Where to search for Scala syntax - reserved words, keywords, operators?

From Dev

Documentation and syntax for ggplot in python

Related Related

  1. 1

    ORACLE syntax: What is this called?

  2. 2

    PHP Weird Syntax - What is it called?

  3. 3

    What language used in scala documentation in lexical expressions?

  4. 4

    What is the syntax and semantics of the `where` keyword?

  5. 5

    What does glGenVertexArraysOES() do and where is the documentation?

  6. 6

    What does glGenVertexArraysOES() do and where is the documentation?

  7. 7

    XML ellipsis / other syntax - what's it called?

  8. 8

    What is SpreadElement in ECMAScript documentation? Is it the same as Spread syntax at MDN?

  9. 9

    What is the use cases of Ignored Variable syntax in Scala?

  10. 10

    What feature of Scala allows for Props[SomeActor] syntax

  11. 11

    What does the syntax function[T] means in scala

  12. 12

    Scala match syntax: What is the block like structure

  13. 13

    In Scala, what syntax rules apply to foreach(println)?

  14. 14

    What is this C# Syntax called and what does it do?

  15. 15

    What is this C# Syntax called and what does it do?

  16. 16

    What is polymorphism, explained simply?

  17. 17

    ExtLibUtil documentation - where do you find what the available functions are?

  18. 18

    What is the name of "${}" and where can I find documentation on them for NetBeans IDE?

  19. 19

    ExtLibUtil documentation - where do you find what the available functions are?

  20. 20

    What does a bash sequence '\033[999D' mean and where is it explained?

  21. 21

    where are the function key row keys explained for the dell inspiron N5010, what does the "A" key do?

  22. 22

    Strange syntax in CImg library, don't know what it's called

  23. 23

    can anyone tell me how this syntax is called and what it does?

  24. 24

    What is "search: { ... }" / "break search" syntax officially called in Java?

  25. 25

    Strange syntax in CImg library, don't know what it's called

  26. 26

    What is this Javascrip/node variable/constant assinging notation/syntax called ?

  27. 27

    Where the architecture of iOS apps is explained?

  28. 28

    Where to search for Scala syntax - reserved words, keywords, operators?

  29. 29

    Documentation and syntax for ggplot in python

HotTag

Archive