Re: Any way to get a warning if a non-boolean type is used in an if expression?
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