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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:50:31+00:00 2026-05-14T21:50:31+00:00

When this code is executed: var a = 24 var b = Array (1,

  • 0

When this code is executed:

var a = 24
var b = Array (1, 2, 3)
a = 42
b = Array (3, 4, 5)
b (1) = 42

I see three (five?) assignments here. What is the name of the method call that is called in such circumstances?
Is it operator overloading?

Update:
Can I create a class and overload assignment? ( x = y not x(1) = y )

  • 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-14T21:50:31+00:00Added an answer on May 14, 2026 at 9:50 pm

    Having this file:

    //assignmethod.scala
    object Main {
      def main(args: Array[String]) {
        var a = 24
        var b = Array (1, 2, 3)
        a = 42
        b = Array (3, 4, 5)
        b (1) = 42
      }
    }
    

    running scalac -print assignmethod.scala gives us:

    [[syntax trees at end of cleanup]]// Scala source: assignmethod.scala
    package <empty> {
      final class Main extends java.lang.Object with ScalaObject {
        def main(args: Array[java.lang.String]): Unit = {
          var a: Int = 24;
          var b: Array[Int] = scala.Array.apply(1, scala.this.Predef.wrapIntArray(Array[Int]{2, 3}));
          a = 42;
          b = scala.Array.apply(3, scala.this.Predef.wrapIntArray(Array[Int]{4, 5}));
          b.update(1, 42)
        };
        def this(): object Main = {
          Main.super.this();
          ()
        }
      }
    }
    

    As you can see the compiler just changes the last one (b (1) = 42) to the method call:

    b.update(1, 42)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have executed this js code: var container=function() { //do something } container.a=function
i came across this problem, my code in the viewWillAppear method is not executed
I have a problem with JavaScript magic. When I execute this code: var page
With this code: var db = google.gears.factory.create('beta.database'); db.open('cominar'); db.execute('CREATE TABLE IF NOT EXISTS Ajax
This code when executed displays the expected output but prints segmentation fault (core dumped)
I have an array of hooks in jQuery that are executed before I load
I have the following code: function Session(name, index) { this.Messages = []; this.Name =
After writing code that can be boiled down to the following: var size=-1; var
There's a number of questions on this that are answered here but I cant
I have an array filled with strings that have the same name as Google

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.