Could anybody help me, and explain what is :/
and then ~
in scala, example:
json = http(:/("api.twitter.com") / "1/users/show.json" <<? Map("screen_name" -> "aloiscochard") >~ { _.getLines.mkString })
from: http://aloiscochard.blogspot.com/2011/05/simple-rest-web-service-client-in-scala.html
In the code that you link to, note the import dispatch._
. This imports the dispatch library.
In that library we find an object :/
that has an apply method, so that's what :/("api.twitter.com")
means.
Also, there is no ~
in the code, either--only a >~
. In Scala, any group of symbols is a method name, which can be used as an operator. So >~
must be a method on something.
Looking around, we find that HandlerVerbs
defines a >~
method that will "Handle response as a scala.io.Source, in a block."
To understand what the code does in detail, you need to understand the dispatch
library, which I don't.
This library seems to be very DSL-heavy. As such, it may be an excellent choice if you are doing lots and lots of dispatch work (because dispatching hopefully can be done in an intuitive and clean way). But it may be a horrible choice for one-off usage, since you have to be quite familiar with the library to understand what it might be doing (due to the choice of very short method names like >~
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With