Re: Avoiding == and = mixup in if statements
Re: Avoiding == and = mixup in if statements
- Subject: Re: Avoiding == and = mixup in if statements
- From: Prachi Gauriar <email@hidden>
- Date: Fri, 21 May 2004 01:53:53 -0500
On May 20, 2004, at 11:57 PM, Nicko van Someren wrote:
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.
A discussion similar to this one got a bit out of hand last year, so
before anyone replies to this message or the previous one, I suggest
you check out this thread in the archives first:
<
http://cocoa.mamasam.com/COCOADEV/2003/06/1/65121.php>
Just a suggestion. :-)
-Prachi
_______________________________________________
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.