The meaning of a = b in object oriented languages

Russell Wallace russell.no.spam at gmail.com
Tue Sep 18 01:45:14 EDT 2007


Summercool wrote:
> so most or all object oriented language do assignment by reference?
> is there any object oriented language actually do assignment by
> value?  I kind of remember in C++, if you do
> 
> Animal a, b;
> 
> a = b will actually be assignment by value.
> while in Java, Python, and Ruby, there are all assignment by
> reference.  ("set by reference")
> 
> Is that the case: if a is an object, then b = a is only copying the
> reference?

Yes, your understanding is exactly correct; C++ will assign by value 
unless you explicitly use pointers, but the other languages will assign 
by reference (except for primitive types).

-- 
"Always look on the bright side of life."
To reply by email, replace no.spam with my last name.



More information about the Python-list mailing list