From: Francis Cianfrocca Date: 2006-05-15T07:38:22+09:00 Subject: Re: begining programmer questions ------=_Part_59130_18218819.1147646297435 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline A lot of people have the mistaken notion that Ruby is not "strongly typed" (perhaps because they confuse dynamic type-resolution with weak typing), an= d this is a good counterexample. You might suppose that Ruby could infer from the syntax info[]=3D that it should create an object of type Array, but in fact the method named []=3D is defined on other classes (such as Hash), and could of course be defined or meta-defined in your own classes. So Ruby doesn't try to guess what class you meant. On 5/14/06, corey konrad <0011@hush.com> wrote: > > i dont know doing info =3D Array.new seems like an array declaration to > me. Couldn the constrution of an array object be implied in just saying > info[] you what what i mean? That would be even more simplified. > > > > corey konrad wrote: > > oh ok thats right it has to be an object in order to be useful. The boo= k > > i am reading didnt mention that in the entire chapter on arrays. thats > > why i didnt get it. > > > > > > > > Michael Gorsuch wrote: > >> When you call 'info[]', the '[]' piece is actually trying to invoke a > >> method > >> 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 al > > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_59130_18218819.1147646297435--