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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:04:24+00:00 2026-05-15T07:04:24+00:00

I am getting a weird error when trying to use a Java map in

  • 0

I am getting a weird error when trying to use a Java map in Scala. This is the snippet of code

val value:Double = map.get(name)
  if (value eq null) map.put(name, time) else map.put(name, value + time)

the map is defined as

val map=new ConcurrentHashMap[String,Double]

and this is the error I am getting

error: type mismatch;
found   : Double
required: ?{val eq: ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method double2Double in object Predef of type (Double)java.lang.Double
and method doubleWrapper in object Predef of type (Double)scala.runtime.RichDouble
are possible conversion functions from Double to ?{val eq: ?}
if (value eq null) map.put(name, time)

I am new to Scala so I am having a hard time parsing the stacktrace. Any help would be appreciated

  • 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-15T07:04:25+00:00Added an answer on May 15, 2026 at 7:04 am

    First, map.get(name) will not return null in the case when name key is not present in the map. It will instead return a Double(0.0).

    Second, the error that you see is because scala is trying to implicitly convert the returned Double value to a type suitable for the eq comparision and it finds more than one implicit conversions in the scope.

    The better way to do what you are doing is

    if (map contains name) map.put(name, map.get(name) + time) 
    else map.put(name, time)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Specify the beginning and ending strings via the environment, and… May 16, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer You are printing your html alright. Right click and look… May 16, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer As far as I can tell, the code you have… May 16, 2026 at 5:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am getting the following error when trying to use the WCF Test Client
I'm getting a weird instance of a NameError when attempting to use a class
I'm getting a weird error and I can't track it down. The stack trace
I'm trying to use Subversion as Maven repo utilizing Maven wagon . If I
Hey there! I'm doing this project and right now I'm trying to: create some
I'm stumling upon a weird problem: The code just wont be able to access
When I try to compile my VB.NET web project, I get an error that
So I'm trying to create a generic select by ID method for a base
I am using apache CXF for the first time. I am trying to establish
I'm playing around in Haskell to try and get the hang of it. I'm

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.