Http (/ * argument here * /) How is this object (Http) used without an explicit or implicit method?

In the example, for encoding with Json using the Send Databinder, Nathan uses an object (Http) without the method shown here:

import dispatch._
import Http._
Http("http://www.fox.com/dollhouse/" >>> System.out )

How he does it?

Thanks for all the answers, unfortunately I was not specific enough ...

It seems that the argument is simply passed to the constructor of the Http class or companion object.

In another example, I saw a different form:

http = new Http
http(/* argument here */)

Is it really a Scala? I think it should be, because the author is an expert at Scala. But that doesn't make sense to me. Actions are usually performed by calling methods on objects, whether explicitly as object.doSomething () or implicitly as object = something (using the apply () method under syntactic sugar).

, , , - . , , , - .

+3
3

:

val http = new Http
http(/* argument here */)

Scala? , , Scala. .

Http . Java. apply Http (/* argument here */). , , Scala - .

, object apply. ( , apply ), new:

val http = Http()

. , .

+3

, , apply . , , , apply.

+6

apply, "" , ( ).

+3

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


All Articles