• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Empty NSStrings, nil NSStrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Empty NSStrings, nil NSStrings


  • Subject: Re: Empty NSStrings, nil NSStrings
  • From: Ondra Cada <email@hidden>
  • Date: Sun, 16 Apr 2006 20:41:28 +0200

Just for Paolo's (or other beginner's) benefit, I can see a possible obfuscation point in the order or Joar's operands (again, sorry if I am wrong and it was completely clear to all readers):

On 16.4.2006, at 20:25, j o a r wrote:

((nil != foo) ? ...);

though I myself don't like the pattern of using "nil <comparation> <expression>", there is a point there: in case you are checking for equality, like


if (nil==foo) ...

and by a typo miss one character writing

if (nil=foo) ....

instead, the compiler would go wild and you can fix the error. If you did the same mistake in the more common order ("if (foo==nil)"), the compiler would not even warn (unless you set -Wparentheses, which has its own drawbacks), and the code would not do what you wanted it to.

(Myself, I much prefer the approach "is there the foo object?" instead to the "is the foo variable content nil?" one--in other words, I would always test "if (!foo) ..." instead of "if (foo==nil)". But that, as Joar rightly says, is a matter of personal preference.)
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Empty NSStrings, nil NSStrings
      • From: Paolo Bertani <email@hidden>
References: 
 >Empty NSStrings, nil NSStrings (From: Paolo Bertani <email@hidden>)
 >Re: Empty NSStrings, nil NSStrings (From: j o a r <email@hidden>)
 >Re: Empty NSStrings, nil NSStrings (From: Ondra Cada <email@hidden>)
 >Re: Empty NSStrings, nil NSStrings (From: j o a r <email@hidden>)
 >Re: Empty NSStrings, nil NSStrings (From: Ondra Cada <email@hidden>)
 >Re: Empty NSStrings, nil NSStrings (From: j o a r <email@hidden>)

  • Prev by Date: Re: Empty NSStrings, nil NSStrings
  • Next by Date: does windowDidClose or not?
  • Previous by thread: Re: Empty NSStrings, nil NSStrings
  • Next by thread: Re: Empty NSStrings, nil NSStrings
  • Index(es):
    • Date
    • Thread