www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Arguments and attributes with the same name

reply Bane <branimir.milosavljevic gmail.com> writes:
 This can be solved if the compiler warns when an assignment is from a 
 variable to the same one.
 
 x = x; // error: assignment has no effect

Nice and useful.
Mar 04 2010
parent =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
On 03/04/2010 02:44 PM, Bane wrote:
 This can be solved if the compiler warns when an assignment is from a
 variable to the same one.

 x = x; // error: assignment has no effect

Nice and useful.

struct A { int i; void opAssign(A a) { i = a.i + 1; } } why not?
Mar 04 2010