« Return to Thread: += and +

Re: Re: += and +

by Jamie Webb-2 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View in Thread

On 2008-01-10 14:09:24 Franco Lombardo wrote:
> >>   var s = "A"
> >>   s += "B" + "C"
> >>   println(s)
> > See issue #92.
>
> Please, can you tell me what is issue #92?
> And is there anyone who can explain me the strange behaviour of s +=
> "B" + "C"?

A ticket in the Scala bug tracker:

  http://lampsvn.epfl.ch/trac/scala/ticket/92

The behaviour is thanks to Scala's precedence rules. The above
parenthesises as:

  (s += "B") + "C"

That is, "B" is appended to s and the result stored back in s, and then
"C" is appended but that result is discarded.

/J

 « Return to Thread: += and +