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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:34:31+00:00 2026-06-10T06:34:31+00:00

Scala’s Map and Set define a + operator that returns a copy of the

  • 0

Scala’s Map and Set define a + operator that returns a copy of the data structure with a single element appended to it. The equivalent operator for Seq is denoted :+.

Is there any reason for this inconsistency?

  • 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-06-10T06:34:33+00:00Added an answer on June 10, 2026 at 6:34 am

    Map and Set has no concept of prepending (+:) or appending (:+), since they are not ordered. To specify which one (appending or prepending) you use, : was added.

    scala> Seq(1,2,3):+4
    res0: Seq[Int] = List(1, 2, 3, 4)
    
    scala> 1+:Seq(2,3,4)
    res1: Seq[Int] = List(1, 2, 3, 4)
    

    Don’t get confused by the order of arguments, in scala if method ends with : it get’s applied in reverse order (not a.method(b) but b.method(a))

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

Sidebar

Related Questions

Scala provides immutable collections, such as Set , List , Map . I understand
scala> Random.shuffle((1 to 10).toSet) res10: scala.collection.immutable.Set[Int] = Set(5, 10, 1, 6, 9, 2, 7,
scala> val m = Map(1 -> 2) m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2) scala>
Scala programmer should have known that this sort of writing : class Person{ var
scala> List(1,2,3) == List(1,2,3) res2: Boolean = true scala> Map(1 -> Olle) == Map(1
Scala's MapLike trait has a method mapValues [C] (f: (B) ⇒ C): Map[A, C]
Scala offers a method called stripMargin that removes the left-hand part of a multiline
In Scala I have a list of objects that represent points and contain x
In Scala, I would like to create a TestNG DataProvider that converts all the
Does Scala have a built in formatter for binary data? For example to print

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.