Re: Avoiding == and = mixup in if statements
Re: Avoiding == and = mixup in if statements
- Subject: Re: Avoiding == and = mixup in if statements
- From: Ondra Cada <email@hidden>
- Date: Fri, 21 May 2004 20:28:23 +0200
Steve,
On 21.5.2004, at 19:32, Steve Bird wrote:
>
Can you explain how I can remember to put the arguments in backwards,
>
if I can't remember to use "==" instead of "="?
;)
Actually, in my *personal* opinion the best pattern for pointers (which
includes, of course, objects) is omitting the "nil" altogether: a
condition
if (myObj) whatever...
reads very intuitively "if there's myObj do whatever" (or, "if
(!myObj)..." reads "if there's no myObj..."). And, of course, no typo
is possible.
That of course does not solve cases with a more complicated
expressions, like
if (myObj==[NSNull null]) ...
for these I personally would recommend the (already mentioned by
others) -Wparentheses warning.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.