Re: Avoiding == and = mixup in if statements
Re: Avoiding == and = mixup in if statements
- Subject: Re: Avoiding == and = mixup in if statements
- From: Nicko van Someren <email@hidden>
- Date: Fri, 21 May 2004 05:57:40 +0100
On 21 May 2004, at 4:47, Chris Pavicich wrote:
Why not write:
if ( nil == myObject)
{ doSomething(); }
If you miss the extra '=' the compiler will complain.
An argument against solving the problem this way is that now the code
here is not naturally representing what the programmer is thinking.
Most people are thinking "is my object pointer nil?", not "is nil equal
to the value of my object pointer". In my experience allowing code to
better represent what you are thinking is very good for both avoiding
bugs and allowing you to understand the code when you revisit it later.
Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.