From: Michael Gorsuch Date: 2006-05-15T08:46:58+09:00 Subject: Re: begining programmer questions ------=_Part_28897_5789107.1147650414886 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Here is the code I am going by: def input puts "Enter some info" info =3D [] info << gets.chomp while info.last !=3D "exit" info << gets.chomp end info.sort puts info end Now, take a look at the while loop. You start the loop, put data in to 'info', and then start over. At the top of the loop, you have to see what is stored in 'info'. On 5/14/06, corey konrad <0011@hush.com> wrote: > > so gets changes the array into a string object during each loop and then > just keeps changing the what is in that string object ok i understand > that. I still dont understand the issue with "exit" thouse i dont see > how i am putting exit into anything, i am just testing to see if info is > =3D=3D to exit i thought. I dont know maybe i should stick with networkin= g, > lol this stuff is frustrating i dont know how a person could do this 8 > hours a day. > > > > > Michael Gorsuch wrote: > > 'gets' will read a string from input and build a new string object. > > > > When you did 'info =3D gets.chomp', you wiped out your array and made i= t a > > simple String object. > > > > 'exit' is being stored because your program logic is placing the string > > into > > the Array, and then checking to see if the last retrieved value is > > 'exit'. > > > > You may be better off using a temporary variable first, checking it, an= d > > then storing it. > > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_28897_5789107.1147650414886--