Created
November 25, 2013 12:46
-
-
Save krisajenkins/7640726 to your computer and use it in GitHub Desktop.
Scala, we need to talk about what 'immutable' means.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Thing { var x = 5 } | |
val things = scala.collection.immutable.List(new Thing) | |
println(things.head.x) // Prints 5 | |
things.head.x = 10 // WAT? | |
println(things.head.x) // Prints 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment