From: corey konrad <0011@...> Date: 2006-05-10T17:26:06+09:00 Subject: Re: range stuart yarus wrote: > On 5/10/06, corey konrad <0011@hush.com> wrote: >> another code example from my book doesnt work with the ruby interpreter >> >> parts = ("Part A" .. "Part G") >> parts.length #�> 7 > > A range is a specification which can be used for making ordered lists > ("lists" is not a ruby word). You can't count the elements of a range > because there aren't any, except for the two objects specifying the > beginning and end of the range. > > You can make a "list" from a range. In fact, you can make an array > from a range and then count the objects in the array. > > For example: > parts = ("Part A" .. "Part G") > parts_array = parts.to_a > parts.length # -> 7 > > which can be shortened to "parts.to_a.length". hmm ok i guess the author made a mistake in this book i just wanted to check to make sure it wasnt a bug in my ruby or something. -- Posted via http://www.ruby-forum.com/.