From: Harry Date: 2007-03-16T10:19:39+09:00 Subject: Re: to_a > > ok, yeah now i understand why the () are there i just didnt see that for > some reason. > > See when i tried > > > array = 1..8 > > array.to_a > > puts array[1] > > my view was that i was creating a range and assigning it to array and > then taking that range in array and converting it to an array by using > array.to_a. I had no idea i was just creating a new array there is no > way to tell that from looking at it for me even now, to me that code > looks like i am transforming the range stored in array... into an array. > My view was that array.to_a meant, take the range stored in array and > convert it to an array but that isnt what its doing its just converting > the variable array into an empty array? I dont know i still feel like i > am missing something that is going on behind the scenes, learning ruby > as a first programming language kind of seems like learning short hand > english first instead of becoming fluent in english grammer. > Maybe using the variable name 'array' is tricking you into thinking it actually is an array. Try changing the variable name, look at the code and think about the explanation that Alex gave you. Try this. #foo = 1..8 #foo.to_a #puts foo[1] foo = 1..8 p foo x = foo.to_a p x puts x[1] Harry -- http://www.kakueki.com/ruby/list.html Japanese Ruby List Subjects in English