Top "Mutability" questions

Mutability is property of any function, variable or expression whose values are subject to changes with "side-effects". In other words, the value does not have referential transparency.

Aren't Python strings immutable? Then why does a + " " + b work?

My understanding was that Python strings are immutable. I tried the following code: a = "Dog" b = "eats" c = "treats" print …

python string immutability mutability
Swift make method parameter mutable?

How can I deal with this error without creating additional variable? func reduceToZero(x:Int) -> Int { while (x != 0) { …

swift syntax immutability mutability
How do I work around mutability in moment.js?

I've run into a problem where I have to store the initial values of a moment object but I'm having …

javascript object immutability momentjs mutability
How to iterate through a Hashmap, print the key/value and remove the value in Rust?

This should be a trivial task in any language. This isn't working in Rust. use std::collections::HashMap; fn do_…

hashmap rust iteration mutability
How do I create a Vec from a range and shuffle it?

I have the following code: extern crate rand; use rand::{thread_rng, Rng}; fn main() { let mut vec: Vec<…

iterator immutability rust mutability
Which types are mutable and immutable in the Google Go Language?

In Google Go, I read that Strings are immutable, ok but are int's? What about other types? As a slightly …

go immutability mutability
Scala: Mutable vs. Immutable Object Performance - OutOfMemoryError

I wanted to compare the performance characteristics of immutable.Map and mutable.Map in Scala for a similar operation (namely, …

performance memory scala garbage-collection mutability