| View previous topic :: View next topic |
| Author |
Message |
ovigo22
Joined: 15 May 2006 Posts: 130
|
| You can have as many 'else if' as you like |
| |
|
|
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
| Cool... but it seems like extra keystrokes for a single situation |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
Not necesarily .. switch is good for: if (X =1 ) { action } else if (X = 2) { action } else if (X = 3) {action} else {action} where the LHS of the condition is always the same
(think about multiple 'else' clasuses .. when would any but the first get executed? |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
| Interesting |
| |
|
|
AmeliaR
Joined: 31 May 2006 Posts: 142
|
| ovigo22, heh, well not to get offtrack, but for that I think a for loop would be better :-P |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
| Where? |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
| Well, basically, I have a dropdown menu with four options. I need to set up a statement to handle all four. which would be the coolest/most elegant way to approach this? |
| |
|
|
ovigo22
Joined: 15 May 2006 Posts: 130
|
kadamat,switch would be as the LHS will always be the selectedIndex ..
(object full of functions == perl) |
| |
|
|
Gladis
Joined: 24 May 2006 Posts: 108
|
| Perl must die |
| |
|
|
kadamat
Joined: 01 Jun 2006 Posts: 88
|
| Thanks guys. So switch it is! |
| |
|
|
|