From: Jon Bauman Date: 2006-04-14T00:14:15+09:00 Subject: Re: Range#size Jeremy Tregunna wrote: > On 13-Apr-06, at 9:20 AM, Meinrad Recheis wrote: > >> does anyone object to adding the method :size to class Range? > > Forgive me for being blunt, but Ranges don't have a fixed size, so > how could you possibly measure it accurately? Force class > implementers to implement not only a #succ method for their objects, > but also a #range_size method which would give a formula for > calculating the size? I mean seriously... You know, it's not as though all range operations work with all range types anyway: $ irb --simple-prompt >> (1.0..2.0).each {|x| p x } TypeError: can't iterate from Float from (irb):1:in `each' from (irb):1 So, what would be wrong with allowing size for object that implement the - operation and giving an error for those that don't? -- Posted via http://www.ruby-forum.com/.