I'm trying to find a use for doWhile that's unique to it.
I feel like you could just use While?
Many thanks
Sam
I'm trying to find a use for doWhile that's unique to it.
I feel like you could just use While?
Many thanks
Sam
For further actions, you may consider blocking this person and/or reporting abuse
Steve Sewell -
Sohail @chakraframer.com -
Mike Young -
Jenny C -
Top comments (2)
For any case where you need the instructions within the loop to execute at least once, regardless of the while condition.
A common contrived example is continuously asking for valid user input. My condition to check if the input is valid would be within the while, however I need the request for input to execute at least once before checking the condition, so I use a do...while.
Thank you! makes sense. :)