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 7659447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:20:03+00:00 2026-05-31T13:20:03+00:00

Possible Duplicate: “new” keyword in Scala Ive noticed that creating certain instances in Scala

  • 0

Possible Duplicate:
“new” keyword in Scala

Ive noticed that creating certain instances in Scala you can leave off using new. When is it required that a developer use new? And why do some objects allow you to miss off using it?

Thanks

List(“this”,”is”,”a”,”list”) creates a List of those four strings; no
new required

Map(“foo” -> 45, “bar” ->76) creates a Map of String to Int, no new
required and no clumsy helper class.

Taken from here..

  • 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-31T13:20:03+00:00Added an answer on May 31, 2026 at 1:20 pm

    In general the scala collection classes define factory methods in their companion object using the apply method. The List("this","is","a","list") and Map("foo" -> 45, "bar" ->76) are syntactic sugar for calling those apply methods. Using this convention is fairly idiomatic scala.

    In addition if you define a case class C(i: Int) it also defines a factory C.apply(i: Int) method which can be called as C(i). So no new needed.

    Other than that, the new is required to create objects.

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

Sidebar

Related Questions

Possible Duplicate: Python “extend” for a dictionary I know that Python list can be
Possible Duplicate: is there any other way of creating an object without using “new”
Possible Duplicate: When to use “strictfp” keyword in java? What is the use of
Possible Duplicate: “using” keyword in java I'm transitioning from C# to java, so please
Possible Duplicate: What is the purpose of the expression “new String(…)” in Java? I've
Possible Duplicate: Install xCode 3.2.3 w/ iPhone SDK 4, get “Base SDK missing”, can't
Possible Duplicate: C++'s “placement new” Help with a c++ statement I work in a
Possible Duplicate: Why does gcc have “â” in all its error messages? New to
Possible Duplicate: What is the purpose of the expression “new String(…)” in Java? It's
Possible Duplicate: Scala “<-” for comprehension Could someone please explain how the <- operator

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.