Re: Why after updating Array element I still get old array values?
Oliver Ruebenacker <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAA=X4OAbC41U5ukA7_sQD5GWJySdGE=FCu4V4eKPjxS7q-9Tpg@mail.gmail.com> |
Hello,
Strange - works as expected for me:
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java
1.7.0_79).
Type in expressions to have them evaluated.
Type :help for more information.
scala> var compactWay = Array("I", "like", "this", "way")
compactWay: Array[String] = Array(I, like, this, way)
scala> compactWay(0) = "We"
scala> println(compactWay.mkString(" "))
We like this way
scala> var secondList = Array("Something else")
secondList: Array[String] = Array(Something else)
scala> var thirdList = compactWay++secondList
thirdList: Array[String] = Array(We, like, this, way, Something else)
Best, Oliver
On Thu, Jul 23, 2015 at 3:15 PM, Sebastian M Cheung <
[email protected]> wrote:
> Why after updating Array element I still get old array values?
>
>
>
> var compactWay = Array("I", "like", "this", "way")
>
> >compactWay: Array[String] = Array(I, like, this, way)
>
>
> compactWay(0) = "We"
>
> println(compactWay.mkString(" "))
>
> >We like this way res3: Unit = ()
>
>
> var secondList = Array("Something else")
>
> var thirdList = compactWay++secondList
>
> >thirdList: Array[String] = Array(I, like, this, way, Something else)
>
> (expecting to see Array(We, like, this, way, Something else)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal
<http://www.type2diabetesgenetics.org/>, Broad Institute
<http://www.broadinstitute.org/>
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.