From: Dark Ambient Date: 2006-06-27T04:19:17+09:00 Subject: Re: Stumped:beginners question On 6/26/06, Matthew Smillie wrote: > On Jun 26, 2006, at 19:26, Dark Ambient wrote: > Your biggest problem in the code you put up is that you're using the > same variable for several different things: a (apparently redundant) > parameter to the method, a loop condition, and to hold user input - > it's much better, especially when you're learning to program, to use > separate variables for these separate concerns. > > There are several problems with the code, one of which is (again) the > bad choice of loop condition, observe your code stripped down to only > the bits which affect the loop continuing or not: > > sort = '' > while sort == '' > sort = gets.etc.etc # sort != '' > end > > So, at the end of the loop, sort != '', and the loop terminates. Ok a 30w light bulb went off so now I see that I've changed the value of sort and ended the loop, but, what I don't understand is if the loop terminating or cycling is dependent on the user input then the initialization of sort should match the gets call. Does my seemingly convoluted thinking make sense here ? If I left sort alone in the first 2 lines above, but then assigned another variable = gets.....,then I won't know the user wants to quit. Stuart