Scala parameters pattern (Spray routing example)
Sorry about the vague title...wasn't sure how to characterize this.
I've seen/used a certain code construction in Scala for some time but I
don't know how it works. It looks like this (example from Spray routing):
path( "foo" / Segment / Segment ) { (a,b) => { // <-- What's this style
with a,b?
...
}}
In this example, the Segements in the path are bound to a and b
respectively inside the associated block. I know how to use this pattern
but how does it work? Why didn't it bind something to "foo"?
I'm not so interested in how spray works for my purpose here, but what
facility of Scala is this, and how would I write my own?
Thanks, Greg
No comments:
Post a Comment