• Post Reply Bookmark Topic Watch Topic
  • New Topic

frustrated by this while loop  RSS feed

 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
please just look at the while loop in this code, it is really frustrating for me, what is the problem?
thanks.


 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Firstly, which while loop? There are two in your code.

Secondly, tell us the details.

*Is it doing something you don't expect it to?

*Is it failing to do something you do expect it to do?

* Is it failing to compile (and if so show the compiler output).

* Is there an Exception (and if so show the full stacktrace).
 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
thank you.
i understood my problem
 
Tim Cooke
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad you've solved your own problem. In the interest of sharing and making the most of this thread I invite you to run through what the problem was and how you solved it?
 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,
It was my stupid misunderstanding, I thought in every line of a while , the while checks for the condition, whereas it just checks the condition in the whle(condition) line, tha's it.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Freed wrote:It was my stupid misunderstanding, I thought in every line of a while , the while checks for the condition, whereas it just checks the condition in the whle(condition) line, tha's it.

Not stupid at all...If I said "keep repeating these steps while the light is green: turn around, jump, clap your hands, and sing a song", if you were in the middle of the song and the light turned purple, you'd probably stop singing right away. If you just finished turning and saw the purple light, you wouldn't jump or clap...You'd stop as soon as you noticed.

I can see why you'd think a program would work that way...but it doesn't. Look at it this way - now you know, and you'll never forget again.

 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is more like a red light on the road. You keep going until you reach the red light; you do not stop 100 yards before it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!