Re: get rid of warning "suggest parenthesis around assignment used as truth value"
Re: get rid of warning "suggest parenthesis around assignment used as truth value"
- Subject: Re: get rid of warning "suggest parenthesis around assignment used as truth value"
- From: Scott Ribe <email@hidden>
- Date: Thu, 20 Nov 2008 13:24:11 -0700
- Thread-topic: get rid of warning "suggest parenthesis around assignment used as truth value"
> But seriously, I can't think of a single instance (outside of school)
> that I've read (or written) code in which someone wrote '=' when they
> meant '=='.
It's happened to me several times. I find it easy to spot in old code or
code written by someone else. But in code that I just wrote, it's sometimes
hard, because of the tendency to read the code as I damn well meant to write
it combined with the very small visual difference ;-)
> It seems like such an obvious mistake that, even if/when it does
> happen, it would be caught almost immediately by running the code or
> via a unit test.
You're assigning a value, by accident, then taking a branch that should only
have been taken if the assignment had been redundant to begin with. Yes
thorough testing will eventually catch it, but these things can pass a
surprising number of tests. And anyway, I prefer to catch everything I can
before testing begins.
Even so, I still don't like the warning--but I do use it.
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
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