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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:35:42+00:00 2026-05-16T18:35:42+00:00

I wrote a function very similar to this: def writeMyEl (x: TypeA, y: TypeB,

  • 0

I wrote a function very similar to this:

def writeMyEl (x: TypeA, y: TypeB, z : TypeC) {
  if (myMutableHashMap.contains((x, y)))
    myMutableHashMap(x, y) = z else
      myMutableHashMap += (x, y) -> z
}

In real code Types A and B are enumerations and C is a case class. myMutableHashMap is defined as a val of type scala.collection.mutable.HashMap[(TypeA, TypeB), TypeC] inside the same class as the writeMyEl function.

The Scala (2.8) compiler says:

error: too many arguments for method update: (key: (TypeA, TypeB),value: TypeC)Unit

What am I doing wrong?

  • 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-16T18:35:43+00:00Added an answer on May 16, 2026 at 6:35 pm

    Try myMutableHashMap((x, y)) = z. In fact, you don’t need the check, since the documentation for += says “Adds a new key/value pair to this map. If the map already contains a mapping for the key, it will be overridden by the new value.” So your function can just be written as

    def writeMyEl (x: TypeA, y: TypeB, z : TypeC) {
      myMutableHashMap += (x, y) -> z
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert function object to function. I wrote this code, but it
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
I have this Array i wrote a function MostFreq that takes an array of
I wrote code to set permission of the folder. Function I developed was public
Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem
I wrote a SQL function to convert a datetime value in SQL to a
I wrote a while loop in a function, but don't know how to stop
I wrote a managed C++ class that has the following function: void EndPointsMappingWrapper::GetLastError(char* strErrorMessage)
I just wrote the following C++ function to programmatically determine how much RAM a
I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do

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.