• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loops Conditionals

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you test more than one conditional in the same loop statement?
Thanks,
Landon
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can use any boolean expression.
(there aren't limits to usage variables in such expressions)
Other example:

[ January 08, 2004: Message edited by: Igor Ko ]
[ edited to turn off smilies, which were interfering with the code display -ds ]
[ January 08, 2004: Message edited by: Dirk Schreckmann ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, but you also need to be careful. remember that with the && and || operators, as soon as the statement can be determined, it stops looking at the other parts...
also, just because you CAN do something, doesn't mean you should do something...
i've seen IF conditions with upwards of 12 terms, nested 4 or 5 parens deep.
this is EXTREMELY HARD to write, and even worse, harder to debug 6 months down the road.
if you can break up your tests at all, debugging is so much simpler.

note: there are better ways to do this, but this works ok.
[ January 08, 2004: Message edited by: fred rosenberger ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic