Re: Avoiding == and = mixup in if statements
Re: Avoiding == and = mixup in if statements
- Subject: Re: Avoiding == and = mixup in if statements
- From: Greg Hurrell <email@hidden>
- Date: Sun, 23 May 2004 17:01:45 +0200
El 21/05/2004, a las 4:10, Christoffer Lerno escribis:
Java disallows stuff like
if (myObject=nil) { dosomething }
Is it possible to maybe disallow the same potential error when I'm
writing obj-c programs? Could I do something with the pre-processor
perhaps?
Another way:
if (!myObject)
{
doSomething;
}
And another way:
#define unless(expr) if(!(expr))
unless (myObject)
{
doSomething;
}
And as has been noted, if you have your compiler warnings turned on
appropriately, you'll be warned if you try to do "if (myObject = nil)"
anyway...
Greg
_______________________________________________
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.