Range#size, Range#length

Apparently size and length are missing from
the Range class nowadays.

This surprises me a little. Is it because of
Float ranges or something?

I’ve made do with range.entries.size, which
works fine.

What’s the rationale here? I’m curious.

Thanks,
Hal

There was a lengthy discussion on the list about this a few months ago.
The size of float ranges was one issue. Here’s a length to one thread:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-
8&threadm=Pine.LNX.4.33.0302121350410.3138-
100000%40eli.fsl.noaa.gov&rnum=1&prev=/
groups%3Fq%3Druby%2Brange%2Blength%2Bsize%26hl%3Den%26lr%3D%26ie%3DUTF-
8%26oe%3DUTF-8%26sa%3DN%26tab%3Dwg

I think the decision comes down to saying that if you are using ranges
as a form of constructor for an array, you should think of your range
object in those terms – i.e., explicitly call an iterator to count the
number of entries.

The more I think about it, range is an unusual thing (very useful,
memory efficient, but odd among Ruby objects in that it is really a
function).

···

On Sunday, May 25, 2003, at 04:53 PM, Hal E. Fulton wrote:

Apparently size and length are missing from
the Range class nowadays.

This surprises me a little. Is it because of
Float ranges or something?

I’ve made do with range.entries.size, which
works fine.

What’s the rationale here? I’m curious.

[snip]

You’re right about the Float range part…
[ruby-talk:64479]:

Range serves purpose of both

(a) sequence of values from beg to end (need “succ” to work)
(b) interval from beg to end

When values are Strings, Range works as (a), whereas for Floats, it
works as (b), and both for Fixnum.

The reason I removed “length” and “size” from Range is that you cannot
tell which role a range takes.

···

On Mon, May 26, 2003 at 05:53:53AM +0900, Hal E. Fulton wrote:

Apparently size and length are missing from
the Range class nowadays.

This surprises me a little. Is it because of
Float ranges or something?

I’ve made do with range.entries.size, which
works fine.

What’s the rationale here? I’m curious.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

‘Ooohh… “FreeBSD is faster over loopback, when compared to Linux
over the wire”. Film at 11.’
– Linus Torvalds