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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:29:37+00:00 2026-05-20T02:29:37+00:00

What does the symbol -> mean in the context of a Map in Scala?

  • 0

What does the symbol -> mean in the context of a Map in Scala?

Scala’s Predef class offers an implicit conversion that lets one write
key -> value as an alternate syntax for the pair (key, value).
I read it in ScalaByExample but fail to see how this works for Maps.

  • 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-20T02:29:38+00:00Added an answer on May 20, 2026 at 2:29 am

    The -> operator is a shorthand for associating a key with a value when used in the context of a map. In some languages, you are simply allowed to pass the pair of the key and value (usually with the key in the first position and the value in the second) to the constructor or one of the various methods on a map and it will be handled appropriately — this is also allowed with Scala maps.

    However, Scala also provides the shorthand form of key -> value, which, as you’ve discovered, is defined in Predef via an implicit, to make the association more clear. Essentially it’s saying: “take the item on the left and map it to the item on the right.” You’ll notice if you read the definition of the Map object, that it does not define any methods that obviously use this -> method. Instead, the methods take objects of type Tuple2 (this is a tuple of 2 values: e.g. (item1, item2)), which Scala implicity converts via the method in Predef.

    In some languages, the -> syntax is defined as part of the language itself, but due to the flexibility of Scala, this is able to be defined simply as a method.

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

Sidebar

Related Questions

In the following code from https://www.php.net/manual/en/language.oop5.properties.php what does the <<< symbol mean? <?php class
What does the >> symbol mean? On this page , there's a line that
What does this symbol mean in my Visual Studio IDE? Not the green bar,
What does the # symbol mean when used as a variable prefix in a
Possible Duplicate: Reference - What does this symbol mean in PHP? I have a
Possible Duplicate: Reference - What does this symbol mean in PHP? What's the difference
I couldn't find any documentation on this symbol. What does -? mean when it
Why does IDLE handle one symbol correctly but not another? >>> e = '€'
What does symbol mean as in Load Symbol List? Or as in this example
What does the symbol : mean in PHP?

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.