From: Michael Gorsuch Date: 2006-05-15T07:04:39+09:00 Subject: Re: begining programmer questions ------=_Part_28369_21165703.1147644276613 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline When you call 'info[]', the '[]' piece is actually trying to invoke a metho= d in the object. since 'info' is not delcared as an object, Ruby has no clue what to do. Now, if you did this: info =3D [] or info =3D Array.new You'd be better off. As for stuffing 'info' with data, you can do this: info << gets.comp and info.sort! Does this help you at all? On 5/14/06, corey konrad <0011@hush.com> wrote: > > I was wondering, i thought in Ruby you didnt have to declare variables > but in this little exercise from the book i have the error i get is that > the variable info is undeclared. Basically the exercise is to keep > filling an array with user input until they choose exit and then the > array is sorted and printed out, is that how i would go about doing > that? > > def input > puts "Enter some info" > info[] =3D gets.chomp > while info[] !=3D "exit" > info[] =3D gets.chomp > end > info[].sort > puts "#{info}" > end > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_28369_21165703.1147644276613--