mutability

Is making in-place operations return the object a bad idea?

Is making in-place operations return the object a bad idea? Question: I’m talking mostly about Python here, but I suppose this probably holds for most languages. If I have a mutable object, is it a bad idea to make an in-place operation also return the object? It seems like most examples just modify the object …

Total answers: 4

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

Aren't Python strings immutable? Then why does a + " " + b work? Question: My understanding was that Python strings are immutable. I tried the following code: a = “Dog” b = “eats” c = “treats” print a, b, c # Dog eats treats print a + ” ” + b + ” ” …

Total answers: 22