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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:12:05+00:00 2026-06-13T06:12:05+00:00

I ran into some issues today making assignments to a var field in a

  • 0

I ran into some issues today making assignments to a var field in a case class instance stored in a map. Here’s a simple session in the repl demonstrating the problem:

scala> case class X(var x: Int)
defined class X

scala> val m = Map('x -> X(1))
m: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(1))

scala> m
res0: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(1))

scala> m('x).x = 7

scala> m
res1: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(1))

scala> val x = m('x)
x: X = X(1)

scala> x.x = 7
x.x: Int = 7

scala> x
res2: X = X(7)

scala> m
res3: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(7))

scala> m('x).x_=(8)

scala> m
res5: scala.collection.immutable.Map[Symbol,X] = Map('x -> X(8))

The first attempt at assignment does nothing. However, storing the instance in a val and then doing the assignment works, as does directly calling the assignment method for the field.

I’m using Scala 2.9.2.

If this is expected behavior, it would be nice if someone could explain it to me because I can’t seem to make sense of it right now. If this is a bug then that would be good to know as well.

Either way, it would also be interesting to know where that first m('x).x = 7 assignment is going. I assume something is getting mutated somewhere—I just have no idea what that something could be.

Update: It looks like this only happens in the repl. I just tried compiling the code and the assignment happens as expected. So, what is the repl doing to my assignment?

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

    This seems to be a bug. If one executes this with a 2.10 nightly an error message is thrown:

    scala> m('x).x = 7
    <console>:10: error: ')' expected but string literal found.
     + "m(scala.Symbol("x")).x: Int = " + `$ires0` + "\n" 
                        ^
    

    I created a ticket for this.

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

Sidebar

Related Questions

I recently ran into some issues this week on a web app that I
I recently ran into some issues with android.os.Bundle that I hoped to fix by
I was working on a project and ran into some issues which i dont
When TransactionScope first came out, I ran into some serious issues getting it to
I ran into an odd bug today when I was running some unit tests
Greetings I started developing with WPF yesterday and have ran into some issues. I
I ran into an issue today with an html/css map I am designing. For
Using a shared repo (core.sharedRepository=group) we ran into some issues with git creating read-only
In developing my current app, I ran into some issues that I eventually traced
Rails 3.1 Nested_forms Ran into some issues setting up and might have hacked the

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.