From: Phillip Gawlowski Date: 2007-03-31T04:11:41+09:00 Subject: Re: Newbie needs a pointer dwyer@o2.ie wrote: > Hi all, just started looking at Ruby in earnest today and my logic has failed me already. Can > someone provide some subtle hints are to where the following code needs attension. Its currently > stuck in a continuous loop, and 'q' doesnt exit the loop. > > #a continous loop until 'q' is press > puts "Please enter your name?" > name=gets > while (name!='q') > puts "welcome, #{name}Enter your name again:" > name=gets > > end C:\WINDOWS\system32>irb irb(main):001:0> name = gets q => "q\n" irb(main):002:0> name != 'q' => true irb(main):003:0> quit C:\WINDOWS\system32>ruby -v ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32] Try name = gets.chomp! -- Phillip "CynicalRyan" Gawlowski http://cynicalryan.110mb.com/ Eek! That was supposed to be My Special Law, _MY_ special law, I tell you! T/