Pages: 1 [2]   Go Down
Author Topic: Two ideas  (Read 1668 times)
0 Members and 1 Guest are viewing this topic.
Arlington, MA, USA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

0, I believe... ?

Or am I not understanding your question?

Or was it not directed at me? :-)
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Code:
int foo;
if (foo = getSomeValue()) {
  int bar = doSomethingWithFoo(foo);
}
What that is doing is basically this:

Quote
Code:
int foo = getSomeValue();
if (foo) {
  int bar = doSomethingWithFoo(foo);
}
It's checking to see if foo is true (not false, false = 0).
So it's deciding if foo = getsomevalue() ,which can be said is just foo (as you're simply telling it what foo is), is true.

It's annoying to debug and normally people mean to use == in those situations so generally you wouldn't use that 'shortened version' for anything.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25859
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm gonna force my buddy to write a app
Maybe you could coerce him/her to include a grammar and spelling checker.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: 1 [2]   Go Up
Jump to: