![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
if (selection == 1, 2, 3, 4, 5) It is not comparing selection to 1,2,3,4, or 5. It is comparing selection to 1, then throwing away that result and returning 5 all the time. This means your if test never fails. |
|
|
|
|
|
#12 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
The Dark is ever accurate, but often laconic. Quite over and above the fact that expression evaluation is often improperly coded (val == A | B | C ... instead of val == A || val == B ....), the comma operator is little understood. Many don't even know it exists.
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#13 |
|
Programmer
Join Date: Oct 2005
Posts: 49
Rep Power: 0
![]() |
yea i was wondering why the test didn't fail when i inserted bad input. But now i know that using the commas is a heck of a lot easier way to idiot proof code. So the usage of commas could be a extremely good thing or a terribly retarded thing.
:banana: ITS PEANUT BUTTER JELLY TIME!!!!!! :banana: ^^^^ Im sorry i just had to do it. ![]()
__________________
Dylan Ferguson hence the nickname D-Ferg Got an IPod? Use ManagePod All the cool kids are doing it. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|