From: Gennady Bystritsky Date: 2002-12-31T16:56:05+09:00 Subject: Re: Range#size On Monday, Dec 30, 2002, at 23:26 US/Pacific, Gavin Sinclair wrote: > On Tuesday, December 31, 2002, 6:07:06 PM, Gennady wrote: > >>> Range size is not easily calculatable; imagine when both ends are >>> floats, or strings. > >> Does this mean that there's no Range#each in 1.7 either (I am still >> using 1.6.7)? It seems to me that same considerations regarding floats >> or strings apply to each as well as size. > > Range without #each would be a bit odd, I think. #each on a range of > Strings is no big deal (you can use it to calculate #size if you like. > For some reason, Range#each treats floats like integers: > > irb(main):004:0> (1.1..5.9).each do |i| > irb(main):005:1* puts i > irb(main):006:1> end > 1 > 2 > 3 > 4 > 5 > 1.1..5.9 So why not to have Range#size simply returning a number of iterations that Range#each would undergo, whatever algorithm is involved? However as I understand from the initial question and Matz's reply, Range#size is gone completely in 1.7. > > > Gavin > > >