• 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: Andy Lee <email@hidden>
  • Date: Sat, 19 Oct 2013 08:13:48 -0400

On Oct 18, 2013, at 3:10 PM, Rick Mann <email@hidden> wrote:
>> I can understand still wishing there were a warning, because people coming from Java may be used to its auto-boxing feature, which would return the right thing whether the property is a Boolean (object) or boolean (primitive).  (Apologies if I'm misremembering Java.)
>
> While I tend to like autoboxing, that's irrelevant here. Java had a boolean type requirement in conditional clauses long before it had autoboxing.

With autoboxing, the boolean requirement for "if (x)" allows x to be either a boolean or a Boolean.  You don't have to say "if (x.booleanValue())".  Out of habit, a Java programmer might be more likely to make the same mistake you made in Objective-C (knowing full well what x was), which would make the warning you wished for especially useful for them.

--Andy


 _______________________________________________
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


References: 
 >Re: Any way to get a warning if a non-boolean type is used in an if expression? (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: ENABLE_NS_ASSERTIONS?
  • Next by Date: Generating both signed and unsigned bundles from a build
  • Previous by thread: Re: Any way to get a warning if a non-boolean type is used in an if expression?
  • Next by thread: Programmatically take a heap shot in Instruments?
  • Index(es):
    • Date
    • Thread