Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:40:49+00:00 2026-05-14T02:40:49+00:00

In the example for coding with Json using Databinder Dispatch Nathan uses an Object

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:40:50+00:00Added an answer on May 14, 2026 at 2:40 am

    I’ve seen another form:

    val 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.

    In the first line, the Http class’s constructor is invoked to create a new instance. Nothing different than in Java. In the second line, the Http class’s apply method is invoked on that instance with (/* argument here */). That’s obviously a Scala-specific thing.

    There can be some confusion when the class has a companion object with an apply method. In that case (assuming that apply method just invokes the companion class’s construtor), new instances can be created without the new keyword:

    val http = Http()
    

    creates the new instance. This is an extremely common pattern, though companion object apply methods may do anything and have any signature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example code: # -*- coding: utf-8 -*- from functools import wraps class MyClass(object): def
Using this question as the base is there an alogrithm or coding example to
I've apparently worked myself into a bad coding habit. Here is an example of
Is there any pdf which tells about coding guidelines in objective C. For Example...
When someone codes something for example in MASM, what is it called? Coding in
I mean, is there a coded language with human style coding? For example: Create
I am trying to figure out the best method of displaying a json result
I was the Google Codeing Basics (http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideCodingBasicsOverlay.html#example-collections) and thought: hey this could be way
Are circular class dependencies bad from a coding style point of view? Example: In
Using Pythons (2.7) 'json' module I'm looking to process various JSON feeds. Unfortunately some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.