• 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: !foo vs foo == nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: !foo vs foo == nil


  • Subject: Re: !foo vs foo == nil
  • From: Thomas Engelmeier <email@hidden>
  • Date: Thu, 21 Aug 2008 12:25:36 +0200


Am 21.08.2008 um 11:04 schrieb Negm-Awad Amin:

Sometimes you see in source code something like this:
if( booleanVarOrExpression == YES )
(I think, Rentzsch does it that way, IIRC) and Ithink, that this is simply correct.

Oh, that is another discussion.
Bool != Boolean != bool, and sometimes that can introduce subtle errors if it's not only used to evaluate logical statements but by comparing values, especially to "YES", true and "TRUE".


In an large C++ Cross-Platform project I spotted some subtle problems, IIRC from assignment of an bool to an Boolean for an API that evaluated the values by comparison to "TRUE" or some code assigned it to ints, giving different values for true (1 vs. 0xFF vs. 0xFFFFFFFF). I don't know any more, fixed it, was glad my own coding practices don't leave room for that problems, moved on ;-)...

Regards,
	Tom_E
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: !foo vs foo == nil
      • From: Negm-Awad Amin <email@hidden>
References: 
 >!foo vs foo == nil (From: Torsten Curdt <email@hidden>)
 >Re: !foo vs foo == nil (From: Filip van der Meeren <email@hidden>)
 >Re: !foo vs foo == nil (From: Torsten Curdt <email@hidden>)
 >Re: !foo vs foo == nil (From: "John C. Randolph" <email@hidden>)
 >Re: !foo vs foo == nil (From: "Michael Ash" <email@hidden>)
 >Re: !foo vs foo == nil (From: Thomas Engelmeier <email@hidden>)
 >Re: !foo vs foo == nil (From: Negm-Awad Amin <email@hidden>)

  • Prev by Date: Re: Parse form values from HTTP POST
  • Next by Date: Re: !foo vs foo == nil
  • Previous by thread: Re: !foo vs foo == nil
  • Next by thread: Re: !foo vs foo == nil
  • Index(es):
    • Date
    • Thread