http(/* argument here */) How is this Object (Http) being used without an explicit or implicit meth
Posted
by Randin
on Stack Overflow
See other posts from Stack Overflow
or by Randin
Published on 2010-03-21T00:19:43Z
Indexed on
2010/03/21
7:21 UTC
Read the original article
Hit count: 388
In the example for coding with Json using Databinder Dispatch Nathan uses an Object (Http) without a method, shown here:
import dispatch._
import Http._
Http("http://www.fox.com/dollhouse/" >>> System.out )
How is he doing this?
Thank you for all of the answers unfortunatly I was not specific enough...
It looks like it is simply passing an argument to a constructor of class or companion object Http.
In another example, I've seen another form:
http = new Http
http(/* argument here */)
Is this valid Scala? I guess it must be, because the author is a Scala expert. But it makes no sense to me. Actions are usually performed by invoking methods on objects, whether explicitly as object.doSomething() or implicitly as object = something (using the apply() method underneath the syntactic sugar).
All I can think of is that a constructor is being used to do something in addition to constructing an object. In other words, it is having side effects, such as in this case going off and doing something on the web.
© Stack Overflow or respective owner