Yes, thank you James. Works as expected.  In some of the examples in
the book "input" is initialized with a string.  i.e.

request = ' Compared to Go, Chess is like Tic-Tac-Toe.'
while request != ' stop'
puts ' What would you like to ask C to do?'
request = gets.chomp

Which is what threw me.

Stuart

On 6/23/06, James Fairbairn <james / netlagoon.com> wrote:
> > $stdout.sync = true (due to weird windows buffer stuff)
> > input = ''
> > while input != 'BYE'
> >   input = gets.chomp
> >   if input == input.upcase
> >     puts 'NO, NOT SINCE 1938!'
> >   elsif input == input.downcase
> >     puts 'HUH?! SPEAK UP, SONNY!'
> >   end
> > end
> >
> > What happens is it does exit on BYE but issues the elsif before
> > ending.
>
> You could initialise input before you go into the while loop, and then
> update it at the end of each iteration:
>
> input = gets.chomp
> while input != 'BYE'
>   if input == input.upcase
>     puts 'NO, NOT SINCE 1938!'
>   elsif input == input.downcase
>     puts 'HUH?! SPEAK UP, SONNY!'
>   end
>   input = gets.chomp
> end
>
> See?
>
> James
>
>