On Wed, 18 Aug 2010 22:11:35 -0400, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
Here's something from TDPL, page 292:
string process(string input) { return input; };
string s1 = blah;
string s2 = process(s1);
assert(s1 == blah); // never fails
I've added the return in process(), it
Here's something from TDPL, page 292:
string process(string input) { return input; };
string s1 = blah;
string s2 = process(s1);
assert(s1 == blah); // never fails
I've added the return in process(), it wasn't there. Andrei states that it's
impossible for s2 to be changed after the
On Wednesday, August 18, 2010 19:11:35 Andrej Mitrovic wrote:
It's just nitpicking, I know. And I'm sure Andrei was specifically
documenting only that first example. But I do think it was worth
mentioning that immutability on individual elements isn't a safe bet
unless you're sure the function
Andrej Mitrovic Wrote:
I agree that in this case s1 and s2 will remain the same. But this has to do
*not just* with immutability, but with the fact that s1 is passed by value. I
think that should be mentioned here.
In the first example a string reference is passed by value.
In the second