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

  • Home
  • SEARCH
  • 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 8007641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:53:52+00:00 2026-06-04T17:53:52+00:00

When calling the get method of Scala’s HashMap class, which method is used to

  • 0

When calling the get method of Scala’s HashMap class, which method is used to check if the key exists (i.e. whether a key in the map is equivalent to the supplied one)? Is it == or another one?

The Scala API does not clearly speak about it:

“Optionally returns the value associated with a key”

  • 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-04T17:53:54+00:00Added an answer on June 4, 2026 at 5:53 pm

    Hash maps first check hash value and then check identity. So the “method” is

    key.hashCode == entry.hashCode && key == entry
    

    (where key is the item you’re testing and entry is an item already in the map). In particular, scala.collection.immutable.HashMap uses exactly this form inside its get method (as of Scala version 2.9).

    If you want to change the behavior of identity, you therefore need to override hashCode and of equals, and also you can’t rely upon overridden behavior of the item already in the map; it’s the one you test with whose equal method gets called. (But note that in general, no guarantee is made about whose equals method will be called, so you shouldn’t rely upon this behavior.)

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

Sidebar

Related Questions

I am successfully calling GDirections to get a map with directions between a point
in Scala there is syntactic sugar by calling a method when the method call
Is there any security problem with dynamically calling a method in a class from
I would like to get the calling method java.lang.reflect.Method . NOT the name of
I would like to use the data you get when calling the following URL
I'd like to know if, when i'm calling cudaMemcpy(...) to get memory on the
I can get the unique id like className@2345 of my object by calling its
i deployed my App to my iPhone and get Unknown error calling sqlite3_step (8:
I'm writing an app that is calling a server to get data to show
I am calling oracle package, to get xml file from the package into oracleDataReader.

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.