• 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: Any way to get a warning if a non-boolean type is used in an if expression?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any way to get a warning if a non-boolean type is used in an if expression?


  • Subject: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • From: Quincey Morris <email@hidden>
  • Date: Fri, 18 Oct 2013 11:07:03 -0700

Well, I apologize if I sounded unpleasantly critical. That wasn't the intention.

On Oct 18, 2013, at 07:50 , Jens Alfke <email@hidden> wrote:

Rick did not mean to write “self.active.boolValue”. That is not the point at all. If he had remembered in the moment that ‘active’ was of type ‘NSNumber’, he would have written the proper test. His mistake was misremembering the type and assuming ‘active’ was of type ‘BOOL’ and writing the conditional that way.

On Oct 18, 2013, at 02:24 , Rick Mann <email@hidden> wrote:

I knew exactly what self.active was, and yet I still failed (in one out of half a dozen instances or so) to write "self.active.boolValue", and this cause a pretty tricky symptom that led me on quite a wild goose chase.

Um, one of these things is not like the other.

On Oct 18, 2013, at 00:29 , Rick Mann <email@hidden> wrote:

In my ideal world, bool would be a first-class citizen, and it would be an error to put a non-bool _expression_ in there (there'd be no implicit type conversion to bool).

My point (which perhaps made more sense at 2 am when I came up with it) is that the boolean-ness of 'if (x)' isn't the issue in Rick's case. In C, 'if (x)' is *exactly* equivalent to 'if (x != 0)', which is as boolean-looking a test as Rick could wish, but would be just as wrong as the original code, if 'x' was 'self.active'.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Any way to get a warning if a non-boolean type is used in an if expression?
      • From: Jens Alfke <email@hidden>
References: 
 >Re: Any way to get a warning if a non-boolean type is used in an if expression? (From: Quincey Morris <email@hidden>)
 >Re: Any way to get a warning if a non-boolean type is used in an if expression? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • Next by Date: Zoom is driving me crazy
  • Previous by thread: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • Next by thread: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • Index(es):
    • Date
    • Thread